2010-03-19 32 views
0

嗨,这工作正常在Firefox,但不是IE浏览器。我究竟做错了什么?我在这里先向您的帮助表示感谢!简单的绑定不工作在jQuery中的Radiobutton的IE浏览器

$(document).ready(function(){ 
    $("#radiodiv").buttonset(); 
    $('#radio1').bind("click", function() { 
    alert('Hello'); 
    }); 
} 

<form> 
<div id="radiodiv"> 
    <input type="radio" id="radio1" name="radio" checked="checked" /><label for="radio1">WaveHeight</label> 
    <input type="radio" id="radio2" name="radio" /><label for="radio2">Current</label> 
    <input type="radio" id="radio3" name="radio" /><label for="radio3">WaveHeightDir</label> 
</div> 
</form> 

回答

2

你有一个语法错误在你的JavaScript代码:

$(document).ready(function(){ 
    $("#radiodiv").buttonset(); 
    $('#radio1').bind("click", function() { 
    alert('Hello'); 
    }); 
} 

应该用closestache})被关闭,然后关闭,括号()),然后一个分号(;)如下:

$(document).ready(function(){ 
    $("#radiodiv").buttonset(); 
    $('#radio1').bind("click", function() { 
    alert('Hello'); 
    }); 
}); 

使用网络调试工具,如FireBug并用癸烯编辑t syntax-highlighter可以帮助您轻松捕捉这些类型的语法错误。

0

我一直有同样的问题。它看起来像当你在一个单选按钮组上使用buttonset时,单击并更改事件不会触发。我注意到,捕获标签上的事件工作正常。 。

<div id="buttonGroup1" class='demo'> 
         <input type="radio" id="radio1" name="radio" /><label for="radio1" class='tabButton'>Top 10 FAQ's</label> 
         <input type="radio" id="radio2" name="radio" /><label for="radio2" class='tabButton'>Last 30 Days</label> 
    </div> 

$( 'tabButton ')点击(函数(){ 警报(' 你好'); });

+0

我发现通过下载jQuery v1.8(不是rc3)它修复了这个问题。希望这对你有用:-),但也很好的工作:-) – Jonathan 2010-03-26 14:14:20

相关问题