« Обратно на страницу селекторов
:contains(текст)
Соответствует элементам, которые содержат в себе заданный текст.
Аргументы:
| текст |
Строка |
|
| Текст для поиска. Регистр имеет значение. |
Примеры:
| Name |
Type |
Поиск и подчеркивание всех элементов div, которые содержат в себе «John».
$("div:contains('John')").css("text-decoration", "underline");
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("div:contains('John')").css("text-decoration", "underline");
});
</script>
</head>
<body>
<div>John Resig</div>
<div>George Martin</div>
<div>Malcom John Sinclair</div>
<div>J. Ohn
</body>
</html>