Before we start, the very first thing we should know what is DOM?
DOM stands for Document Object Model. DOM is a platform and language-neutral interface that allows scripts and program to dynamically access and update the content, structure, and style of Document
DOM is divide into 3 parts
- HTML DOM
- XML DOM
- CORE DOM
1. HTML-DOM
Most common method to access the HTML element
- document.getElementById(id) : It is used to find the element by id
- document.getElementByTagName(name): It is used to find the element by tag name
- document.getElementByClassName(name): It is used to find the element by class name
Most common jQuery method to Get HTML attribute
- text(): This method is used to return the text
- html(): This method is used to return Html and text
- val(): this method is used to get the value
Most common jQuery method to Set HTML attribute
- text(“The Code Hubs”): This method is used to set or return text contend of selected elements
- html(“<b> The Code Hubs </b>”): This method is used to set or return text contend of selected elements with include Html
- val(“the code hubs”): This method is used to set the value of the form field
- attr(): This method is used to set or change the attribute value
Most common jQuery Add Html content elements
- append(): This method is used to inset contend at the end of the selected element
- prepend(): This method is used to insert at the beginning of the selected elements
- after(): This method is used to insert an element after the selected element
- before(): This method is used to insert before the selected element
Most common JQuery Remove Html content elements
- remove(): This method is used to remove the selected element and also its child element
- empty() : This method is used to remove only its child element from the selected element
Most common JQuery CSS manipulation method
- addClass(): This method is used to add one or more class to the selected element
- removeClass(): This method is used to remove one or more class from the selected element
- toggleClass(): This method is used to toggles between add/remove class
- css(): This method is used to set or return the style attribute
Most common JQuery Dimension method
- width():This method set or return the width of the element also padding, border, and margin
- height(): This method set or return the height of the element also padding, border, and margin
- innerWidth(): This method set or return the width of the element also includes only padding
- innerHeight(): This method set or return the height of the element also includes only padding
- outerWidth(): This method set or return the width of the element also includes only padding and border
- outerHeight(): This method set or return the height of the element also includes only padding and border