Multiple Elements Selector - Javascript jQuery Selector

Javascript examples for jQuery Selector:element

Description

To select multiple elements using element selector, seperate each element with a comma.

Parameter Description
element Required. Specifies the elements to be selected

The following code shows how to select all <h2>, <div> and <span> elements:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("h2, div, span").css("background-color", "yellow");
});/*  ww w .ja  v  a 2  s  .  c  om*/
</script>
</head>
<body>

<h1>Welcome to My Web Page</h1>
<h2>H2</h2>

<div>div</div>

<p>This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. </p>


</body>
</html>

Related Tutorials