我的网页上有一些单选按钮,它们应该改变放置在它们旁边的 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> Blanco U </span><br /><br/>
</label>
<label class="label_radio" for="sample-radio2">
<input name="opcion" id="dos" value="White Truss" type="radio"/><span> Blanco Truss </span><br/><br/>
</label>
<label class="label_radio" for="sample-radio3">
<input name="opcion" id="tres" value="Black U" type="radio"/><span> Negro U </span><br /><br/>
</label>
<label class="label_radio" for="sample-radio4">
<input name="opcion" id="cuatro" value="Black Truss" type="radio"/><span> Negro Truss </span><br/><br/>
</label>
<br />