现状:jQuery UI的复选框按钮 - 按钮,然后单击兼容性问题 - IE8
我有以下的jQuery:
addButton();
function addButton(){
var div = $("#mydiv");
div.append(addHtml());
addEvents(div);
}
function addEvents(div){
div.find(".toggleButton").button();
div.find(".toggleButton").click(function(e) {
alert("test");
});
}
function addHtml(div){
return "<input class=\"toggleButton\" type=\"checkbox\" id=\"id1\" name=\"name1\" /><label for=\"id1\">Yes</label>";
}
复选框变成一个按钮,但没有信号上的警报单击。为什么按钮部分工作,但不是点击部分?
更新: 这适用于firefox,但不适用于ie-8。不幸的是,我需要它在ie-8中工作。
更新2: 如果我注释掉.button调用,click部分在ie-8中工作。我怎样才能一起工作?
更新3:在Firefox产生 实际的HTML:在IE-8产生
<input class="toggleButton ui-helper-hidden-accessible" id="id1" name="name1" type="checkbox"><label aria-disabled="false" role="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" aria-pressed="false" for="id1"><span class="ui-button-text">Yes</span></label>
实际的HTML:
<INPUT id=id1 class="toggleButton ui-helper-hidden-accessible" type=checkbox name=name1 jQuery1294922695438="218"><LABEL aria-disabled=false class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role=button aria-pressed=false for=id1 jQuery1294922695438="223"><SPAN class=ui-button-text jQuery1294922695438="225">Yes</SPAN></LABEL>
哈哈,我们都在同一时间进行编辑 - 谢谢:) – kralco626 2011-01-13 12:09:28
只是为了确保HTML被转义,因为它是用于回显或其他东西(即浏览器看不到\“) – 2011-01-13 12:10:01
另外:Where 'div'set? – 2011-01-13 12:10:53