开发者

jquery small problem

开发者 https://www.devze.com 2023-01-03 09:35 出处:网络
how can i change this: (this script says that it should hide #writeComment if #tryout is che开发者_开发百科cked )

how can i change this: (this script says that it should hide #writeComment if #tryout is che开发者_开发百科cked )

$('#tryout').click(function () {
  $('#writeComment').toggle(!$(this).attr('checked'));
});

Now i dont want to have a checkbox that you check, but instead this link

<a id="tryout">Click to vote</a>

so then when you click on this "link", #writeComment hides...


You can use .toggle() without a boolean, like this:

$('#tryout').click(function() {
  $('#writeComment').toggle();
});

Just set the display state to what you want it to be initially, internally .toggle() checks if it's :visible, and if it is, calls .hide(), otherwise it calls .show().

0

精彩评论

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