Jquery.not () filter

I have a form with thumbnails of images for selection using checkboxes for upload. I want an image array in jQuery to call Ajax.

2 questions:
- At the top of the table there is a flag for switching all the flags that I want to exclude from the comparison. I looked at jQuery.not (), but I cannot implement it with: checkbox selector
- correct example code?

$(document).ready(function() {
    $('#myform').submit(function() {
        var images = $("input:checkbox", this).map(function() {
            return $(this).attr("name");
        }).get().join();

        alert(images); // outputs: ",check1,check2,check3"
        return false; // cancel submit action by returning false
    });
}); // end doc ready

HTML:

    <form id="myform" action="" >
    <input type="checkbox" id="toggleCheck" onclick="toggleSelectAll()" checked="checked" ><br />

    <input type="checkbox" name="001.jpg" checked="checked" /><br />
    <input type="checkbox" name="002.jpg" checked="checked" /><br />
    <input type="checkbox" name="003.jpg" checked="checked" /><br />
    <br />
    <input type="submit" value="download" >
</form>
+3
source share
2 answers

You can exclude it with an identifier, for example:

$("input:checkbox", this).not("#toggleCheck").map(....

This would preclude the selection of all switches from matching.

+7
source

You can chain as shown below.

    $('input:checkbox:not(#toggleall)').after('this is selected');

. http://jsbin.com/ofecu http://jsbin.com/ofecu/edit

0

Source: https://habr.com/ru/post/1741664/


All Articles