开发者

jQuery Callback Scope

Le开发者_Python百科ts say I have this code

$(document).ready(function()
{
   $('.checkbox').change(function()
   {
      $('.hidden').slideUp('slow', function()
      {
         alert(checkbox value);
      }
   }
}

How do I access the checkboxes value? $(this) doesn't work as you're now in the .hidden element?


You could capture the value in the outer function:

$(document).ready(function() {
    $('.checkbox').change(function() {
        var $checkbox = $(this);
        $('.hidden').slideUp('slow', function() {
            alert($checkbox.val());
        }
    }
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜