[JQuery] 특정 단어가 포함된 행의 색깔 바꾸기

2024. 1. 15.공부/JavaScript

728x90
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>contains demo</title>
  <script src="https://code.jquery.com/jquery-3.7.0.js"></script>
</head>
<body>
 
<div>John Resig</div>
<div>George Martin</div>
<div>Malcom John Sinclair</div>
<div>J. Ohn</div>
 
<script>
$( "div:contains('John')" ).css( "background-color", "#ddd" );
</script>
 
</body>
</html>