05.jQuery - 특정 텍스트 검색 ( 05.Contains )
[ 선택기 필터 : 콘텐트 ]
표현식 | 설명 |
:Contains(text) | 지정한 텍스트를 포함하는 요소들과 일치합니다. |
:empty | 자식을 가지지 않는 모든 요소와 일치됩니다. 더불어, 내부 텍스트를 가지지 않는 요소들도 이에 해당됩니다. |
:has(selector) | 지정된 셀렉터에 해당하는 요소를 갖는 모든 요소들과 일치됩니다. |
:parent | 부모인 모든 요소들과 일치됩니다. 자식 요소를 갖는 요소 뿐만 아니라 텍스트를 갖는 요소들이 이에 해당됩니다. |
05.Contains.htm |
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>특정 텍스트 검색</title> <style type="text/css"> .redColor{ color:Red; } .green{ color:Green; } </style> <script src="jQuery/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { //[1] td 태그내의 텍스트가 RedPlus를 포함하는 요소를 검색 후 배경색을 red $("td:contains('RedPlus')").addClass("redColor"); $("td:contains('Godffs')").addClass("green"); }); </script> </head> <body> <table> <tr> <td>RedPlus</td> </tr> <tr> <td>DotNetKorea</td> </tr> <tr> <td>Godffs</td> </tr> </table> </body> </html> |
결과화면 |
