HTML Manipulation

It refers to writing something on the document or in other words changing the contents of elements and their attributes. We start up with selecting an element and then we palay with it.

.html() and .text()

.html() finds out the html contents of the first matched element and return the same. If more than matches are found, it returns the HTML content of only first element. On the other hand, .text() returns the string containing the combined text of all the matched element. It escapes all the tags present in the document.

Love U
addClass(), hasClass(), toggleClass() and removeClass()

This is used to add , check, toggle or remove a class to the selected element. Many a times, we need to change the design of something when the user clicks a button. This can be done by adding or removing a class which contains the CSS property.



.attr() and .removeAttr()

It gets the value of an attribute for the first element in the set of matched elements. This method of obtaining the attributes value is good as it supports cross-browser consistency. Moreover, it is directly accessible. It can also be used to set the attributes value of any element. Lets see how these all can be used :-

I am reading jQuery tutorial here

.val()

A very important method which is used in obtaining the value of form elements like textbox, select menu etc. It can also be used to set the value of a form element once it is called with some contents as arguments. Lets see how we can read the value of select, checkbox and input field using .val() method

 
  
  
 

Lets see how to modify style of our webpage using jQuery :-

Member Login

Member Login




Not a Member? Sign Up!




Login to comment

Be the first to comment on this topic







  


<<< Wanna review

Continue >>>