-1

Possible Duplicate:
Fire jQuery event on div change

I'm using this tiny plugin to watch for changes in the html: https://github.com/jacobrelkin/jquery-watcher

This works fine, the problem is I need the if condition to validate if it's over 2 times, reason being when the gallery loads and it shifts left and right creates the -moz-grabbing condition twice onload.

I tried doing

  if(  $('#gallery-1').has('div').css('cursor', '-moz-grabbing') > 2)
  if(  $('#gallery-1').has('div').css('cursor', '-moz-grabbing').length > 2)

I also tried putting it in a variable then doing > 2

None of the above seem to be working not sure what I'm doing wrong?

$('.sliderContainer').watch('innerHTML', function() {
    if(  $('#gallery-1').has('div').css('cursor', '-moz-grabbing') ) {
        console.log($('#gallery-1').has('div').css('cursor', '-moz-grabbing'));
        $('#collapse_content_1').toggleClass('collapse_inner_off');
    }
});
Community
  • 1
  • 1
zadubz
  • 1,281
  • 2
  • 21
  • 36

1 Answers1

1

.css('cursor', '-moz-grabbing') actually sets the stylesheet rule. You probably want to use .filter:

$('#gallery-1').has('div').filter(function () {
   return $(this).css('cursor') == '-moz-grabbing';
}).length > 2
Explosion Pills
  • 188,624
  • 52
  • 326
  • 405