我有这样的CSS:更改多个页面上的div的CSS背景图像?
div[data-role="page"]{
min-height: 100%;
width: 100%;
padding: 0px;
margin: 0px;
border: 0px;
background-image:url('../img/blue_background.jpg');}
,这是我的函数:
注: 在函数初始化的变量,则VAL()是一个选择框,改变的时候,被保存在localStorage的。
function saveParam(){
var result=$("#param_results option:selected").val();
var scan=$("#param_scan option:selected").val();
var scan_speed=$("#param_scan_speed option:selected").val();
var scan_bg=$("#param_scan_bg option:selected").val();
var font=$("#param_font option:selected").val();
var screen_bg=$("#param_screen_bg option:selected").val();
var waiting_time=$("#param_waiting_time option:selected").val();
window.localStorage.setItem("param_results", result);
window.localStorage.setItem("param_scan", scan);
window.localStorage.setItem("param_scan_speed", scan_speed);
window.localStorage.setItem("param_scan_bg", scan_bg);
window.localStorage.setItem("param_font", font);
window.localStorage.setItem("param_screen_bg", screen_bg);
window.localStorage.setItem("param_waiting_time", waiting_time);
//$('div[data-role="page"]').css("background-image", "url('../img/green.jpg')");
back();}
我有几个HTML页面,所有的人都在div [数据角色=“页面”]所以他们都具有相同的背景,等等。但是当param_screen_bg改变,我想永久地将背景图像更改为另一个,但它不起作用。最后的评论栏只是试图改变背景,但它仍然不起作用。
编辑: https://jsfiddle.net/42zbcbge/1/
这个的jsfiddle是我想要的一个小例子。当你按下保存按钮,我想改变的CSS背景,为此在页面上太多,但它不改变
;
我做这个样本虽然在一些假设,但我认为你可以处理它: 所以,你可以,例如,做这样的事情“你是说这张照片将来会用到吗? –
每次“param_screen_bg”被改变时,背景也被改变。所以通过永久性的我的意思是,直到应用程序上的某个人改变它,背景将成为新图像 –