开发者

jquery, div with table is not visible when I call show();

<div id="abclink">
    + click here to view
</div>
<div id="abctable" style="display: none;">
    some text here, allot of text
</div>

So using jquery I try and do:

$开发者_如何学JAVA("#abclink").bind("click", function() {

     $("#abctable").show();
});

This doesn't work, and I don't know why?


you have to put a #

$("#abclink").bind("click", function() {

     $("#abctable").show();
});


You might be missing the document.ready function. Also, it might be best to use toggle instead of show:

$(document).ready(function(){
 $("#abclink").bind("click", function() {
  $("#abctable").toggle();
 });
})


I'm guessing #abclink doesn't exist at the point you're trying to bind the event. Are you doing it in the of the page? If so, try putting it in the document.ready event:

$(function() {
    [your code]
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜