LinkedNestBlog

[jQuery] [name*="value"]셀렉터를 포함하는 속성

by jinwon lee

[name*="value"]셀렉터를 포함하는 속성


 

출처:

http://api.jquery.com/attribute-contains-selector/

 

Description:

선택한 속성은 (주어진 substring을 포함하는 value와 함께) 규정된 속성을 가지고 있다.

[name*="value"]은 value를 확인하는 가장 일반적인 jQuery 속성 selector이다.

엘리먼트의 속성 값 내에 셀렉터의 문자열이 나타나면, 그 엘리먼트를 선택할 것이다.

단어 셀렉터를 포함하는 속성과 함께 '비교'를 수행하는 이 셀렉터는 많은 케이스들에 적용할 수 있다.

 

Example:

name 속성에 'man'이 포함된  모든 input들을 찾고, 텍스트 value를 설정해본다.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>attributeContains demo</title>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
 
<input name="man-news">
<input name="milkman">
<input name="letterman2">
<input name="newmilk">
 
<script>
$( "input[name*='man']" ).val( "has man in it!" );
</script>
 
</body>
</html>

 

[jQuery] [name*="value"]셀렉터를 포함하는 속성 · LinkedNest Blog