"JQuery id로 선택"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
(사용자 2명의 중간 판 16개는 보이지 않습니다)
1번째 줄: 1번째 줄:
{{소문자}}
;jQuery getElementById
;jQuery getElementById
;jQuery ID로 핸들 얻기
;jQuery ID로 핸들 얻기
4번째 줄: 5번째 줄:


==방법==
==방법==
<source lang='javascript'>
<syntaxhighlight lang='javascript'>
$("#jmnote")
$("#jmnote")
</source>
</syntaxhighlight>
:→ ID가 jmnote인 것에 접근
:→ ID가 jmnote인 것에 접근


==예제==
==예제==
<source lang='html5'>
<syntaxhighlight lang='html5'>
<!DOCTYPE html>
<!DOCTYPE html>
<meta charset='utf-8' />
<meta charset='utf-8' />
22번째 줄: 23번째 줄:
});
});
</script>
</script>
<form name='my_form'>
<input type='text' id='jmnote' value='apple' />
<input type='text' id='jmnote' value='apple' />
<input type='button' id='test' value='ID로 찾기 테스트' />
<input type='button' id='test' value='ID로 선택 테스트' />
<br/>
</syntaxhighlight>
</form>
*예제: http://zetawiki.com/ex/jquery/by_id.php
</source>
*예제: http://jmnote.com/jq/by_id.php


==같이 보기==
==같이 보기==
*[[jQuery name으로 핸들 얻기]]
*[[jQuery 자식 ID로 선택]]
*[[jQuery name으로 선택]] (jQuery getElementByName)
*[[jQuery class로 선택]] (jQuery getElementByName)
*[[jQuery input type으로 선택]]
*[[jQuery 셀렉터]]
*[[jQuery 셀렉터]]
*[[CSS 아이디 셀렉터]]
*[[자바스크립트 document.getElementById()]]


[[분류: jQuery]]
[[분류: jQuery]]

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

jQuery getElementById
jQuery ID로 핸들 얻기
jQuery ID로 찾기

1 방법[ | ]

$("#jmnote")
→ ID가 jmnote인 것에 접근

2 예제[ | ]

<!DOCTYPE html>
<meta charset='utf-8' />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$("#test").click(function() {
		var myvalue = $("#jmnote").attr("value");
		alert('#jmnote의 value는 ['+myvalue+']입니다.');
	});
});
</script>
<input type='text' id='jmnote' value='apple' />
<input type='button' id='test' value='ID로 선택 테스트' />

3 같이 보기[ | ]

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