The attr method is used to set or get/return element attributes in the document. This tutorial will show you examples of setting different elements attributes on the fly but let us first look at the syntax of attr method.
In order to place or set HTML content by using jQuery to the specified elements in a web page, the jQuery comes up with $.html method.This method is used to retrieve or get the content of the first matched element or
The append method adds content to the end of a given element. For example:
p.append(“content”) will add content to the end of paragraphs in the document.
The jQuery post method ($.post(url)) loads data from the server using HTTP request. As mentioned in the jQuery $.ajax chapter, this is a short form of $.ajax method.
jQuery comes up with $.css method that can be used to change/apply CSS to specified element(s) as well as return style properties for the given elements.
The parent method traverses just one level up and searches the parent of the specified element. In order to get all ancestors of the specified element, i.e. if you specify span and want to get all parents upwards you can use parents method of jQuery.
The jQuery offset method is used to get the position or coordinates of the given element. The offset method is also used to set the coordinates of all matched elements.
The find method is used to “search” the specified element/selector to return downward descendant elements. Where a descendant can be the first level child, second level, third level and so on.