jQuery Tutorial Tutorials - jQuery element selector

jQuery element selector

The element selector selects all elements that have the given html tag name. In javascript we use a similar function getElementsByTagName to do this.

element selector's syntax

$('TagName')

TagName is any html tag name like div,span,p etc.

jQuery element selector Examples

selector description
$('div') Selects all elements with a tag name of div
$('p') Selects all elements with a tag name of p
$('img') Selects all image elements
$('span') Selects all elements with a tag name of span

In following example,when the user click on the button,
A red border will be added to the elements that has a tag name of 'DIV'

example:Select element by html tag name using jQuery
Try now

Date:2019-06-09 01:43:51 From:www.Lautturi.com author:Lautturi