将此Javascript转换为jQuery等效

-1 javascript jquery-validate

你能帮助将以下Javascript转换成jQuery等价吗?

// Let's use a lowercase function name to keep with JavaScript conventions
function selectAll(involker) {
    // Since ASP.NET checkboxes are really HTML input elements
    //  let's get all the inputs
    var inputElements = document.getElementsByTagName('input');

    for (var i = 0; i < inputElements.length; i++) {
        var myElement = inputElements[i];

        // Filter through the input types looking for checkboxes
        if (myElement.type === "checkbox") {

            // Use the involker (our calling element) as the reference 
            //  for our checkbox status
            myElement.checked = involker.checked;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

它是从这里http://wiki.asp.net/page.aspx/281/check-uncheck-checkboxes-in-gridview-using-javascript/

Dav*_*und 5

function selectAll(involker) {
    $('input:checkbox').attr('checked', $(involker).attr('checked'));
}
Run Code Online (Sandbox Code Playgroud)