.add() Method
.add() Add elements to the set of matched elements. HTML: <p>Hello</p><span>Hello Again</span> JQUERY: $("div").css("border", "2px solid red") .add("p") .css("background", "yellow"); This JQ will, Step : 1ย find the div and apply the red to the
addClass() and removeClass()
Jquery .addClass() and .removeClass() used to add or remove CSS class dynamically in the Html element. For Example .addClass() $(โ#p1โฒ).addClass(โcssclass1โ); Add a โcssclass1โ css class to elements that contain id of โp1โณ. .removeClass() $(โ#p1โฒ).removeClass(โcssclass1โ); Remove
.find() vs .filter()
Both filter() and find() methods are very similar, except the former is applies to all the elements, while latter searches child elements only. find() searches the descendants of the elements in the matched set. filter()
Difference Between jQuery Text() And HTML()
ย In this post you will learn about the difference between jQuery text and HTML. .html() - This jQuery function gets/sets the HTML of any element. .text()- This jQuery function gets/sets the text (innertext) of
.append() VS .html()
.append() and .html() is the most usefull method in jQuery.But these are far different from one another, .append() add some value with the existing one. whether .html() do the same but it removes the old
Query append() VS appendTo()
Query append() and appendTo() append() :ย Append to end of the selected element HTML : ย <ul id="test"> <li>test</li> </ul> JQuery : ย jQuery("#test").append("<li>test1</li>"); OUTPUT :ย <ul id="test"> <li>test</li> <li>test1</li> </ul> appendTo :ย Append to
JQuery Selector
JQUERY SELECTORS : 1) selecting a particular element having a specific class $(".class1").css("border", "1px solid red"); 2) select all elements of the page $("*").css("border", "1px solid red"); 3) select an element that having a particular