Q:

toggle function working as expected in jQuery 1.9.1+

I am using jQuery to select a list of checkboxes. I am using the code as outlined in this fiddle:
$(document).ready(function(){
    $('.check:button').toggle(function(){
        $('input:checkbox').attr('checked','checked');
        $(this).val('uncheck all')
    },function(){
        $('input:checkbox').removeAttr('checked');
        $(this).val('check all');        
    })
})

http://jsfiddle.net/gubhaju/Vj6wY/3/
It was working in the fiddle, but not on my site (the button was disappearing). I then saw that the fiddle was using version 1.4.4, whereas my site was using version 2.1.1. After playing with the fiddle, I found that only with jQuery versions 1.8.3 and lower was the select working. What changed between 1.8.3 and 1.9.2? How can I modify this code so that it works for my version?

A:

As I showed you in my comment, there are quite a few changes in the versions of jQuery that you refer to. You can use the jQuery Migrate plugin (made by the jQuery team) to help troubleshoot the changes, but in a nutshell you can boil your code down to:

$('.check').click(function () {
    $('input:checkbox').prop('checked', !$('input:checkbox').prop('checked'));
    $(this).val(($(this).val() == 'uncheck all') ? 'check all' : 'uncheck all')
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="button" class="check" value="check all" />
<input type="checkbox" class="cb-element" />Checkbox 1
<input type="checkbox" class="cb-element" />Checkbox 2
<input type="checkbox" class="cb-element" />Checkbox 3

