开发者

jQuery Callback Scope

开发者 https://www.devze.com 2022-12-10 02:47 出处:网络
Le开发者_Python百科ts say I have this code $(document).ready(function() { $(\'.checkbox\').change(function()

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

精彩评论

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