Filter selected elements by class and id - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:filter

Description

Filter selected elements by class and id

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(){
    $("p").filter(".intro,#outro").css("background-color", "yellow");
});/*from w w w  . j a  va 2  s  . c o m*/
</script>
</head>
<body>

<h1>Welcome to My Homepage</h1>

<p>test</p>
<p class="intro">test</p>
<p id="outro">test</p>
<p>test</p>

</body>
</html>

Related Tutorials