我已经尝试了以下所有操作来删除背景图片,但在我使用标记为答案的解决方案之前它没有工作。
$(document.body).on("click", "#lnkFAQ", function () {
document.getElementById("bodyContent").style.backgroundImage = '';
document.getElementById("bodyContent").style.height = 10;
if (document.all) {
document.body.style.removeAttribute('background-image');
}
else {
document.body.style.removeProperty('background-image');
}
$("#bodyContent").css("background-image",'url("")');
});
和Site.css
/* Set padding to keep content from hitting the edges */
.body-content {
padding-left: 15px;
padding-right: 15px;
height: 100%;
background-image: url("/Content/Img/MainPageBackground.jpg");
background-repeat: no-repeat;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: 100% 100%;
background-position: center;
}
答案 0 :(得分:0)
$("#bodyContent").css("background-image",'none');
OR
$("#bodyContent").attr("style","background-image:none");