jQuery can be used to select HTML elements using element selector. Below are some of the examples of how to use selectors.
- $(<’element>’) - Selects all elements with the given tag name.
- $(‘p’) – Selects all Paragraph Elements
- $(‘a’) – Selects all Anchor tags in side a web page
- $(‘I’) - Selects all Italic tags in the webpage
- $(‘input[type=text]’) – Selects all textboxes in side a webpage
Selecting multiple elements
$(‘p,a,div,span’) – Selects all p, a, div, span elements in the web page.
<script>$("p").after( $("b") );</script>
The above script selects all p and makes the content after <p> tag as bold.
Selecting all the elements
$(‘*’) – This will select all html elements in web form
No comments:
Post a Comment