0

我的网页上有一些单选按钮,它们应该改变放置在它们旁边的 div 的背景,它在 FF、chrome、opera 和 safari 中正确完成,但在 IE 中没有。

编码:

<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 />
4

1 回答 1

0

对于 Internet Explorer,属性的格式必须相同,甚至是空格。尝试使用“背景”属性。

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

`对于jQuery:

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

IE 7+ 必须工作。

于 2013-05-07T13:27:47.327 回答