0

Hi i make list by php nearly 500~ value in a table (Sil = Delete)

table

i already use jquery for my project

is there any plugin that allows you make checked multiple checkbox in jquery if they move the mouse on 2 parent div while mouse left button is on clicked

2 Answers2

1

Yes you can, like this:

var mouseIsDown;

$(document).on('mousedown', function() {    
    mouseIsDown = true;
});

$(document).on('mouseup', function() {
    mouseIsDown = false;
});

$('td').on('mouseenter', function() {        
    if(mouseIsDown) {
        $(this).find('input[type=checkbox]').prop('checked', true);
    }
});

See the demo: http://jsfiddle.net/nuKEK/

Piet van Dongen
  • 1,629
  • 10
  • 13
0

yes it is fairly easy! And already closely answered on another topic here on SO.

To get an idea, hence the following simple code below.

PS: This is taken from mouseover while mousedown

You only have to replace the .node wit ha class your checkboxes have in common, and instead of setting css you have to toggle (or check) your selector (i.e: your checkbox)

Enjoy... :)

$(document).ready(function(){

  var isDown = false;   // Tracks status of mouse button

  $(document).mousedown(function() {
    isDown = true;      // When mouse goes down, set isDown to true
  })
  .mouseup(function() {
    isDown = false;    // When mouse goes up, set isDown to false
  });

  $(".node").mouseover(function(){
    if(isDown) {        // Only change css if mouse is down
       $(this).css({background:"#333333"});
    }
  });
});

Edit:

To check/uncheck a checkbox you may use

$('.myCheckbox').prop('checked', true);
Community
  • 1
  • 1
Oliver M Grech
  • 3,071
  • 1
  • 21
  • 36