jQuery id로 선택

Jmnote bot (토론 | 기여)님의 2020년 11월 2일 (월) 02:53 판 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

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