JQuery

From eBabel wiki
Jump to: navigation, search

Get jQuery version in the console

$().jquery

Trigger event after typing in a box and a pause

$(selector).keyup(function () {
  typewatch(function () {
    // executed only 500 ms after the last keyup event.
  }, 500);
});

Implementation:

var typewatch = (function(){
  var timer = 0;
  return function(callback, ms){
    clearTimeout (timer);
    timer = setTimeout(callback, ms);
  }  
})();

Source: Thread on Stackoverflow

Modal jQuery popup

bPopup is a really nice modal jQuery popup, with lots of variations.

Jquery selector with wildcard

Source: answer on StackOverflow

To get all the elements starting with "jander" you should use:

$("[id^=jander]")

To get those that end with "jander"

$("[id$=jander]")

See also the JQuery documentation.

Find all elements wider than a given width

$("*").filter(function () {
   return $(this).width() > 400;
}).hide();