Useful Jquery Snippets - Part 1
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
JavaScript
$("#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 checkedCode $('#edit-checkbox-id').is(':checked');
|
//HoverJavaScript $("#ID").hover(function () {
},
function () {
});
|
//Dynamically adding target attributes for all anchor links except our domainCode $("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
Join the conversation! Your thoughts help the community grow.