JQuery Handling Data
The following are the JQuery library functions to handle data for your DOM elements.
Add Class: .$(selector).addClass(class)
The .addClass() method is used to add or insert a CSS class to a specified element.
Has Class: $(selector).hasClass(class)
The .hasClass() method is used to check the existence of a specified css class in the selected element.
Remove Class: $(selector).removeClass(classname)
The .removeClass() method is used to remove CSS class from the selected element.
Clone: $(selector).clone(includeEvents)
The .clone() method is used to make duplicate copies of the selected elements.
Replaceall: $(content).replaceAll(selector)
The .replaceAll() method is used to replace the selected elements with the specified content.
Replacewith: $(content).replaceAll(selector)
The .replaceWith() method is used to replace the selected elements with the specified content.
The .append() method allows to insert or append content to the end of the specified element.
The .appendTo() is more or less similar to “append” function which allows to insert or append content to the end of the specified element.
The .prepend() method allows to insert or append content at the beginning of the specified element.
The .prependTo() is more or less similar to “prepend” function which allows to insert or append content to the beginning of the specified element.
The .html() method allows to insert html style to the matched element. You can change the HTML style of the text in a particular element.
The .text() method allows to insert text to the matched element. You can combine the text of elements or even replace the text in a particular element.
Following are the properties of the inserting data around an element:
The wrap() method is used to wrap a specified HTML element around each of the selected element.
The unwrap() method is contrary to the wrap method and removes the parent element which is around the selected element.
The wrapAll() method is used to wrap all the specified HTML elements into a single wrapper element.
The wrapinner method is used to wrap the specified elements of HTML around the content of each element that is selected.
The .after() method allows to insert or append content after the specified element.
The .before() method allows to insert or append content before the specified element.
The .insertAfter() is more or less similar to “after” which performs the same task of allowing to insert the content after the specified element.
Insert Before: .insertBefore()
The .insertBefore() is more or less similar to “before” which performs the same task task of allowing to insert the content before the specified element.
The CSS style property is used to return the property value of an element. The .css() allows to change the style property of an element.
The height style property is used to return the height of a particular element.
The innerHeight style property is used to return the height of a particular element with padding value.
The outerHeight style property can be used to return the height of a particular element with padding, border and margin values.
The width() style property is used to get the width of an element.
The innerWidth style property is used to return the width of an element with padding value.
The outerWidth style property is used to return the width of a particular element with padding, border and margin.
The offset style property is used to return the left and top position value of a particular element in pixels.
The .position style property is used to find out the position of the current element in the document.
The scrolltop() style property is used to get the vertical position of the scrollbar in an element.
The scrollleft() style property is used to get the horizontal position of the scrollbar in an element.