【发布时间】:2011-07-02 13:46:09
【问题描述】:
这里的小提琴http://jsfiddle.net/mjmitche/KvwGw/21/,当你提交表单时,会出现一个新的表单,并且背景颜色也会发生变化。
在 wordpress 博客上,我试图在提交表单时更改背景图片。图片在这里上传到服务器
www.example.com/wp-content/themes/thesis_18/custom/images/strawhat.jpg
然后像这样使用 css(在我的自定义 wordpress 主题中)显示
body.custom {
background: #8db6b6 url('images/subway.jpg') repeat;
}
在我的愚蠢中,我最初尝试使用下面的代码使背景图像更改不成功,但是由于背景图像已上传到服务器,我现在意识到/认为需要一些 Ajax 来更改提交时的背景图像,但我一直不知道该怎么做
有谁知道我将如何进行 ajax 调用来做到这一点?
$("#submit").click(function(){
$(".contactform").hide(1000,function(){
$(".contactforms").css({display:"block"});
$("body.custom").css({background: "url('images/strawhat.jpg') repeat;"});
});
});
$("#send").click(function(){
$(".contactforms").hide(1000)
});
更新 我按照第一响应者的建议尝试了这个(写出路径),但没有奏效。
$("#submit").click(function(){
$(".contactform").hide(1000,function(){
$(".contactforms").css({display:"block"});
$("body.custom").css({background: "url('/wp-content/themes/thesis_18/custom/images/strawhat.jpg') repeat;"});
});
});
$("#send").click(function(){
$(".contactforms").hide(1000)
});
【问题讨论】: