开发者

removeAttr working in FF but not in IE

I want to disable all "a" tags from a dynamically (using JavaScript) created table using jQuery.

I tried

$("ta开发者_StackOverflow社区bleId a").removeAttr("href");
$("tableId a").removeAttr("onclick");

This is working in FF but not in IE


Try neutralizing the links with a loop:

$("tableId a").each(function() {
  $(this).attr('href', '#');
  $(this).attr('onclick', 'javascript:void(0);');
});


Use prop. removeAttr doesn't work for inline onclick events on IE 6,7 and 8.

$("tableId a").prop("onclick", null);


IE does not support table id's, but you can embed the table inside a div:

<div id=...>
    <table>...</table>
</div>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜