What is DOM ?
------------
The HTML DOM is a standard object model and programming interface for HTML. It defines:
- The HTML elements as objects
- The properties of all HTML elements
- The events for all HTML elements
- The methods to access all HTML elements
e.g.
<html>
<head>
<title>Simple HTML</title>
<script type="javascript">
function LoadMeFirst(){
alert("Html Dom loading.....");
}
function ClickME(){
alert("Dom Loaded and hence the button is clicked");
var accessingTheParagraphText = document.getElementsByTagName('p')[0].innerHTML;
}
</script>
</head>
<body onLoad="LoadMeFirst()">
<p>A simple paragraph</p>
<input type="button" id="myButton" value="MyButton" onClick="ClickME()" />
</body>
</html>
In the above code snippet example,
- The HTML elements are - HTML,HEAD,TITLE,BODY,P,INPUT
- The button properties are - TYPE,ID,VALUE
- The Event for
a) BODY is: onLoad
b) BUTTON is: onClick
- Method to access the HTML elements - getElementsByTagName
What is DOM selector in jquery (AKA JQuery Selector) ?
-------------------------------------------------------
An excerpt from my article (
http://www.dotnetfunda.com/articles/show/1918/let-us-learn-jquery-part-2-of-9jquery-selectors )
jQuery selector($),the vital part of JQuery, allow
Html elements to be selected and manipulated (Check out the 4th point of DOM answer provided above ) .It finds the elements by Element Name,Element ID or class and returns a sequence of matched DOM elements upon a successful match. We can they apply methods or logics on those collection for further processing.
Syntax:
$(Selector Expression)
OR
jQuery(Selector Expression)
Types of JQuery Selectors
- Single Element Name Selectors
- Multiple Selectors
- Id Selectors
- CSS Selectors
- Attribute Selectors
- Element Visibility Selectors
- Form Field Selectors
- Parent-Child Selectors
Hope this helps . Let me know in case you have any doubt.
--
Thanks & Regards,
RNA Team
Kumarkrishna184, if this helps please login to Mark As Answer. | Alert Moderator