我试图为我的网站构建一个背景更改器,并且它工作正常,除非在移动到其他页面时更改会丢失。jQuery背景更改器在所有页面中保留吗?
我试过几种方法,当你改变页面但没有喜悦的时候改变它。
这里是jQuery的有一些测试图像:
$(function() {
$(".bgCollection").change(function() {
if ($("#wood").is(":checked")) {
$('#background img:first').attr('src', 'http://cdnimg.visualizeus.com/thumbs/7f/78/gfx,wood-7f78592c9a6ed3390492c560c5ac6fec_h.jpg');
}
if ($("#steel").is(":checked")) {
$('#background img:first').attr('src', 'http://www.aroorsteelcorporation.com/full-images/stainless-steel-834007.jpg');
}
if ($("#metal").is(":checked")) {
$('#background img:first').attr('src', 'http://i00.i.aliimg.com/photo/v0/468538622/Brushed_metal_texture_prepainted_metal.jpg');
}
}); });
而这里的HTML:
<input name="BG" id="wood" type="radio" value="" class="bgCollection" />
<label for="radio">
Wood
</label>
<input name="BG" id="steel" type="radio" class="bgCollection"/>
<label for="radio">
Steel
</label>
<input name="BG" id="metal" type="radio" value="" class="bgCollection"/>
<label for="radio">
Black metal
</label>
我试图当前SRC值传递给一个变量,使脚本设置上页面加载但无法让它工作。
任何帮助将是伟大的。 谢谢, 亚伦。
您可能想使用由JavaScript设置的cookie来执行此操作。 – 2013-02-22 10:15:30