Blog

Useful Jquery Snippets - Part 1

Posted by Raja Krishnamurthy Blogs | JQuery Apr 14, 2011
These are some very useful Jquery snippets which would come in handy while dealing with Jquery.
Given below are some useful Jquery snippets. Hope you find it useful.

//Check All or Uncheck All

 
$("#chkAll").toggle(
function() {
$("input[@type='checkbox']").not('#chkAll').each(function() {
this.checked = true;
});
},
function() {
$("input[@type='checkbox']").not('#chkAll').each(function() {
this.checked = false;
});
});
});

//checking if a checkbox is checked


 $('#edit-checkbox-id').is(':checked'); 

//Hover


 $("#ID").hover(function () {
// do mouse over something
},
function () {
// do mouse out something
});

//Dynamically adding target attributes for all anchor links except our domain

  $("a[href^=http://]").not("a[href^=http://www.yourdomain]").attr("target", "blank");

I would share some more in my next blog entry.

Happy Scripting!!!

Cheers,
Raja



comments
COMMENT USING
PREMIUM SPONSORS
Infragistics is experts in technology and design, and passionate about helping you build highly performant and stylish applications that solve problems, deliver inspiration, and maximize results.
HTML 5 + JQUERY CONTROLS
SPONSORED BY