In jquery, you can easily use CSS class names and IDs to get elements.
For example:
1 ID: #id
$ (' #ida ')-selects all elements with an ID of IDA, regardless of the tag name of the element.
$ (' Div#ida ')-Select all div tag elements with id Ida.
2 Class:.classname
$ ('. ClassA ')-Select the class name to have a classA of all elements, regardless of their label name.
$ (' Div.classa ')-Select the class name that has a classA for all DIV elements.
The complete example is as follows:
<HTML>
<head>
<title>jquery Get element with class name and id</title>
<scripttype= "Text/javascript" src= "jquery-1.3.2.min.js" ></script>
</Head>
<scripttype= "Text/javascript" >
$ (document). Ready (function () {
var $element = $ ('. Classabc '). html ();
alert ($element);
var $element = $ (' #idABC '). html ();
alert ($element);
});
</Script>
<body>
<H1>jquery Get element with class name and id</H1>
<divclass= "classabc" >
</Div>
<divid= "IdABC" >
This was belong to ' div id= ' IdABC '
</Div>
</Body>
</HTML>
Effect Figure 1:
Click OK after the effect: