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

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


==예제 소스==
²==예제 소스==
<source lang='html5'>
<syntaxhighlight lang='html'>
<!DOCTYPE html>
<input type='text' name='hello' value='world' />
<meta charset='utf-8' />
<button id='test'>이름으로 선택 테스트</button>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
 
<script type="text/javascript">
<script src="//code.jquery.com/jquery.min.js"></script>
$(document).ready(function(){
<script>
$("#test").click(function() {
$("#test").click(function() {
var myvalue = $("input[name=jmnote]").attr("value");
  alert( $("input[name={{hello}}{{{{}}}}]").attr("value") );
alert( myvalue );
});
});
});
</script>
</script>
<input type='text' name='jmnote' value='apple' />
</syntaxhighlight>
<input type='button' id='test' value='이름으로 선택 테스트' />
<jsfiddle>85bxfyht</jsfiddle>
</source>
:→ 버튼을 누르면 hello라는 이름을 가진 input text의 value인 world이 출력된다.
:→ 버튼을 누르면 jmnote라는 이름을 가진 input text의 value인 apple이 출력된다.
*예제: http://zetawiki.com/ex/jquery/by_name.php


==같이 보기==
==같이 보기==

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 }}