:lang() Selector - Javascript jQuery Selector

Javascript examples for jQuery Selector:lang

Description

The :lang() selector selects elements by the language attribute starting value.

The following code shows how to select all <p> elements with a lang attribute value that starts with "it":

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:lang(it)").css("background-color", "yellow");
});//from   w  w w .j a va 2s  .  co m
</script>
</head>
<body>

<p>I live in Italy.</p>
<p lang="it">Ciao bella!</p>
<p lang="it-it">Ciao bella!</p>
<p lang="en-it">Ciao bella!</p>
<p lang="it-en">Ciao bella!</p>
</body>
</html>

Related Tutorials