2013-05-07 50 views
0

我的網頁上有一些單選按鈕,它們應該會改變放在旁邊的div上的背景,它在FF,鉻合金,歌劇和Safari瀏覽器中正確完成,但不在IE中。在Internet Explorer中不會改變的背景

代碼:

<script src="jquery-1.9.1.min.js" type="text/javascript"></script> 
<link rel="stylesheet" href="stylecopia.css" type="text/css"> 
<script type="text/javascript"> 
    $(document).ready(function(){ 
     $("#uno").click(function() {$("#cambiar").css("background-image","url(../wp-content/uploads/blanco2patas.jpg)")}); 
     $("#dos").click(function() {$("#cambiar").css("background-image","url(../wp-content/uploads/blanco4patas.jpg)")}); 
     $("#tres").click(function() {$("#cambiar").css("background-image","url(../wp-content/uploads/negro2patas.jpg)")}); 
     $("#cuatro").click(function() {$("#cambiar").css("background-image","url(../wp-content/uploads/negro4patas.jpg)")}); 
    }); 
</script> 
<script> 
    function comprobar() { 
     inputs=document.getElementsByTagName('input'); 
     for (x=0;x<inputs.length;x++) { 
      if (inputs[x].value==""||inputs[x].value==" ") { 
       alert('Hay un campo vacío, termine el formulario'); 
       return (false); 
      } 
     } 
     return true; 
    } 
</script> 
<!--PAGE CONTENTS !--> 
<div id="cambiar"></div> 
<form action="p.php" onSubmit="return comprobar()" name="formulario" method="POST"> 
<label class="label_radio" for="sample-radio1"> 
<input name="opcion" required id="uno" checked="checked" value="White U" type="radio"/><span>&nbsp;Blanco U&nbsp;</span><br /><br/> 
</label> 
<label class="label_radio" for="sample-radio2"> 
<input name="opcion" id="dos" value="White Truss" type="radio"/><span>&nbsp;Blanco Truss&nbsp;</span><br/><br/> 
</label> 
<label class="label_radio" for="sample-radio3"> 
<input name="opcion" id="tres" value="Black U" type="radio"/><span>&nbsp;Negro U&nbsp;&nbsp;</span><br /><br/> 
</label> 
<label class="label_radio" for="sample-radio4"> 
<input name="opcion" id="cuatro" value="Black Truss" type="radio"/><span>&nbsp;Negro Truss&nbsp;&nbsp;</span><br/><br/> 
</label> 
<br /> 

回答

0

對於Internet Explorer,屬性的格式必須是一樣的,甚至spaces.Try使用 '背景' 屬性。

background:transparent url(../wp-content/uploads/blanco2patas.jpg); 

'的jQuery:

$(this).css("background", "url(../wp-content/uploads/negro4patas.jpg)"); 

IE 7+必須工作。

+0

它的工作原理,認爲我的背景顯示太大了,不是說這與問題有關,謝謝! – cobcena 2013-05-08 06:48:04