开发者

Get the check event without a click (jQuery)

开发者 https://www.devze.com 2023-03-22 19:35 出处:网络
Here\'s my problem, i searched for some solutions in vain. So, i have the checkbox range selection plugin on my website. Moreover, i have a function on checkbox click.

Here's my problem, i searched for some solutions in vain. So, i have the checkbox range selection plugin on my website. Moreover, i have a function on checkbox click. I want to fuse both functionnalities : when i click on a checkbox, the click function runs. But, if i want to run the function on each checkbox affected by the range selection (by shift+click), how can i get this event ? I tried to catch it with .change() function, with no result, the only checkbox triggering the function if the clicked one. Other checkboxes are checked, but the function doesn't run for them...

Here's a part of code, if you want :

// I enable the range selection on desired checkboxes
$('.shift').enableCheckboxRangeSelection();
// Here i want to catch the checking event from the range 
// selection and alert something to confirm
$(".colorlabel").change(function() { alert('ok'); });

So, i just get 1 alert : the clicked checkbox, not the others. So, is there any solution to catch the check event without clicking ? I thought at :checked selector, but that's not an eve开发者_StackOverflow中文版nt... Other solution would be executing another function after the range selection, using :checked, but i can't. For exemple, i want to colorize a div background. I check a color, a checkbox in this div, and the div colorize in the selected color while the checkbox is checking. Then, i want to colorize a group of other checkboxes in another color :checked selector won't work correctly as it will colorize each div in the same color... You see what i mean ?

Thank's in advance, i hope i'm clear enough... :)

0

精彩评论

暂无评论...
验证码 换一张
取 消