0% found this document useful (0 votes)
20 views

Jquery Element Selector

The element selector selects all elements with a given tag name by calling the getElementsByTagName() function. It finds every element that matches the specified tag name. For example, $("div") selects all <div> elements on the page and applies a red border to demonstrate the element selector.

Uploaded by

anand
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Jquery Element Selector

The element selector selects all elements with a given tag name by calling the getElementsByTagName() function. It finds every element that matches the specified tag name. For example, $("div") selects all <div> elements on the page and applies a red border to demonstrate the element selector.

Uploaded by

anand
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Element Selector (element)

Categories: Selectors > Basic

element selector
Description: Selects all elements with the given tag name.

version added: 1.0jQuery( "element" )

element: An element to search for. Refers to the tagName of DOM nodes.


JavaScript's getElementsByTagName() function is called to return the appropriate elements
when this expression is used.

Example:
Finds every DIV element.

1
2
3
4
5
6
7
8
9
10

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>element demo</title>
<style>
div, span {
width: 60px;
height: 60px;
float: left;
padding: 10px;
margin: 10px;
background-color: #eee;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<div>DIV1</div>
<div>DIV2</div>
<span>SPAN</span>
<script>

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

Demo:

$( "div" ).css( "border", "9px solid red" );


</script>
</body>
</html>

You might also like