2017-07-08 101 views
-1

逗人我试图改变使用上点击jQuery的DIV背景图像,如图代码其工作下面所有的浏览器除了IE以外.....帮助,请背景图像是使用IE浏览器的jQuery 11个

<div id="section1" class="section111"> 
     <div class="container"> 
      <div style="width: 100%; z-index: 999999999;" class="ServicesTitle"> 
       <p class="Main_TitaleServices">SERVICES & SOLUTIONS</p> 
       <p class="slogan">Full Solutions for a Perfect Business </p> 
      </div> 
      <div id="title-underline" style="margin-bottom: -30px;"> 
       <img src="../../App_Themes/ThemeEn/Images/title-underline.png"> 
      </div> 
      <div class="firstrow"> 
       <div class="col-lg-3 divServices "> 
       </div> 
       </div> 

     </div> 
    </div> 
不改变

这里是脚本

<script> 
$(function() { 
$("#WebsiteDevelopment").click(function() { 
    $("#section1").css("background-image", "url(/App_Themes/ThemeEn/Images/webdevelopment.jpg !important") 
    /

}); 
$("#btnWebsiteDevelopment").click(function() { 


    $("#section1").css("background-image", "url(/App_Themes/ThemeEn/Images/section1bg.png") 

}); 
}); 
</script> 
+0

的[动态地切换 '背景图像' 中的IE不工作]可能的复制(https://stackoverflow.com/questions/3205110/动态切换背景图像不工作在ie) –

+0

可能重复的[如何在HTML中设置背景图像在Internet Explorer中工作?](https://stackoverflow.com/questions/19449185/how-在设置背景图像在HTML中,工作在互联网浏览器) – Shiladitya

+0

你尝试删除!重要? – itacode

回答

0

尝试设置background而不是background-image

<script> 
$(function() { 
$("#WebsiteDevelopment").click(function() { 
    $("#section1").css("background", "url(/App_Themes/ThemeEn/Images/webdevelopment.jpg !important") 
    /

}); 
$("#btnWebsiteDevelopment").click(function() { 


    $("#section1").css("background", "url(/App_Themes/ThemeEn/Images/section1bg.png") 

}); 
}); 
</script> 

或者使用纯javascript方法,

document.getElementById('section1').backgroundImage = "url('url(/App_Themes/ThemeEn/Images/webdevelopment.jpg !important')"; 
+0

亲爱的AKA,我尝试过使用背景,但仍然不工作 –

+0

我已经更新了答案。使用第二个JavaScript修复。 –

+0

感谢其使用背景 –

相关问题