"JQuery input name으로 선택"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
(다른 사용자 한 명의 중간 판 하나는 보이지 않습니다)
5번째 줄: 5번째 줄:
;jQuery 폼 요소 이름으로 선택
;jQuery 폼 요소 이름으로 선택


==예제 소스==
²==예제 소스==
<source lang='html'>
<syntaxhighlight lang='html'>
<input type='text' name='hello' value='world' />
<input type='text' name='hello' value='world' />
<button id='test'>이름으로 선택 테스트</button>
<button id='test'>이름으로 선택 테스트</button>
13번째 줄: 13번째 줄:
<script>
<script>
$("#test").click(function() {
$("#test").click(function() {
   alert( $("input[name=hello]").attr("value") );
   alert( $("input[name={{hello}}{{{{}}}}]").attr("value") );
});
});
</script>
</script>
</source>
</syntaxhighlight>
<jsfiddle>85bxfyht</jsfiddle>
<jsfiddle>85bxfyht</jsfiddle>
:→ 버튼을 누르면 hello라는 이름을 가진 input text의 value인 world이 출력된다.
:→ 버튼을 누르면 hello라는 이름을 가진 input text의 value인 world이 출력된다.

2020년 11월 2일 (월) 02:53 기준 최신판

jQuery getElementById
jQuery 이름으로 찾기
jQuery name으로 핸들 얻기
jQuery 폼 요소 이름으로 선택

²==예제 소스==

<input type='text' name='hello' value='world' />
<button id='test'>이름으로 선택 테스트</button>

<script src="//code.jquery.com/jquery.min.js"></script>
<script>
$("#test").click(function() {
  alert( $("input[name={{hello}}{{{{}}}}]").attr("value") );
});
</script>
→ 버튼을 누르면 hello라는 이름을 가진 input text의 value인 world이 출력된다.

같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}