Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery drag to select, constrained to elements, rather than typical drag box

I want to use a drag to select feature, but rather than select a square area on screen, and select anything within that square, I want to select any element between my initial choice and the one I release the click on.

This is best explained visually. I do not want to do this:

What I don't want to do

Instead I want to do this:

What I want to do

like image 612
Colin Avatar asked Oct 26 '25 14:10

Colin


1 Answers

If your boxes are within a list structure (ul or ol) you could detect the first and last boxes that the mouse has been dragged over and iterate through the collection using their identifiers as first and last indices to highlight as necessary.

like image 51
Iain B Avatar answered Oct 29 '25 06:10

Iain B



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!