Sunday 20 November 2011

.blind

     
     
     

.blind handles event(s)

 

 

$('#foo').bind('mouseenter mouseleave', function() {
  $(this).toggleClass('entered');
});

$('#foo').bind('EVENT1 EVENT2', function() {
//what it will happens
}); 

 

OR

$('#foo').bind({
  click: function() {
    // do something on click
  },
  mouseenter: function() {
    // do something on mouseenter
  }
});

$('#foo').bind('click', function() {
  alert($(this).text());
}); 

 

 

passing data

var message = 'Spoon!';
$('#foo').bind('click', {msg: message}, function(event) {
  alert(event.data.msg);
});
message = 'Not in the face!';
$('#bar').bind('click', {msg: message}, function(event) {
  alert(event.data.msg);
}); 

 

 

 

function foo(e) {

 console.log(e.type);

};

$('li').bind({

  'click': foo,

  'mouseover': foo,

  'mouseout': foo

});

 

 

 

No comments:

Post a Comment