The advantages of using jQuery are:
* JavaScript enhancement without the overhead of learning new syntax * Ability to keep the code simple, clear, readable and reusable * Eradication of the requirement of writing repetitious and complex loops and DOM scripting library calls
1 Comment
Features of jQuery are :
* Effects and animations * Ajax * Extensibility * DOM element selections functions * Events * CSS manipulation * Utilities – such as browser version and the each function. * JavaScript Plugins * DOM traversal and modification.
$(”tr:odd”).css(”background-color”, “#bbbbff”);
$(”tr:even”).css(”background-color”, “#bbbbff”); $(”tr:last”).css({backgroundColor: ‘yellow’, fontWeight: ‘bolder’}); $(”div,span,p.myClass”).css(”border”,”1px solid green”);
the border will be apply in all div,span ,p.myClass class element. There are three way to change the URL for a Hyperlink using jQuery.
1- $(“a”).attr(“href”, “http://www.phpinterviewquestion.com/”); 2- $(“a[href='http://www.phpinterviewquestion.com/']“) .attr(‘href’, ‘http://phpinterviewquestion.com/’); 3- $(“a[href^='http://phpinterviewquestion.com']“).each(function() { this.href = this.href.replace(/^http:\/\/beta\.phpinterviewquestion\.com/, “http://phpinterviewquestion.com”); Here is the example of toggled element using the :visible or :hidden selectors.
var vis = $(’#formdiv’).is(’:visible’); var hide= $(’#formdiv’).is(’:hidden’); $(document).ready(function(){
$(“table tr:eq(3)).css(“background”,”#000″); }) ; $(‘li:nth-child(1)’) selects the first while $(‘li:eq(1)’) selects the second. Because jQuery’s implementation of :nth-child(n) is strictly derived from the CSS specification, the value of n is “1-indexed”, meaning that the counting starts at 1. For all other selector expressions, however, jQuery follows JavaScript’s “0-indexed” counting. |