Home  >  Article  >  Web Front-end  >  How to use jQuery :lang()

How to use jQuery :lang()

藏色散人
藏色散人Original
2020-11-17 11:51:311601browse

jQuery :lang() selector is used to select elements that specify the language attribute lang. Its usage syntax is "$(":lang(language)")". The value must be the entire word, or it can be a separate , can also be followed by a connector.

How to use jQuery :lang()

Recommended: "javascript basic tutorial"

jQuery :lang() selector

Example

Select all

elements whose lang attribute is "it":

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title></title>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
  $("p:lang(it)").css("background-color","yellow");
});
</script>
</head>
<body>

<p>我住在意大利。</p>
<p>Ciao bella!</p>

</body>
</html>

Running effect:

How to use jQuery :lang()

Definition and usage

:lang() selector selects elements with the specified language attribute (lang).

Note: The value must be the entire word, either alone, such as, or followed by a connector (-), such as.

Grammar

$(":lang(language)")

The above is the detailed content of How to use jQuery :lang(). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn