selector - Select a class except another class in jquery -
this question has answer here:
i select element has .handle class not have .exception class-
html-
<div class="handle exception"> 1 <div> <div class="handle"> 2 <div> $(document).on('click', '.handle', function (e) { //i want select 2nd div. });
any help?
you can use :not
selector
$(document).on('click', '.handle:not(.exception)', function (e) { //i want select 2nd div. });
or select 2nd .handle class element can use :eq(1)
or nth-child(2)
'.handle:eq(1)' // index start 0 1 select 2nd 1 '.handle:nth-child(2)' // index start 1 2 select 2nd 1
Comments
Post a Comment