Grab the name of an element with jquery

Here is a example without knowing more of your code:

$(function () {
    $('input:checkbox').click(function () {
        $(this).prop('disabled', true);
        var iName = this.name;
        $.ajax({
            url: "file.php",
            data: {
                'inputname': iName
            },
            success: function (data) {
                alert(data.returned_val);
            }
        })
    })
})

Demo here

If you want to reach the input via name directly you need to use double backslasshes to escape the square brackets and reach that input via name. Use:

$('input[name=aisis_options\\[package_Aisis-Related-Posts-Package-master\\]]')

Leave a Comment