[심플] jQuery on 간단한 연습 예

2674 단어 jquery
jQuery on의 간단한 연습 예는 다음과 같습니다.
     
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>jquery on  </title>
<script type="text/javascript" src="../../js/jquery-2.1.0.js"></script>
<script>
	$(function() {
		$('#testDiv').on('click', '#search_button', function() {
			var searchVar = $.trim($('#search_input').val());
			var readVar = $.trim($('#read_input').val());
			console.log(searchVar + "----=" + readVar);
		});
		$('#operDiv').on('click', '#add_button', function() {
			var searchVar = $.trim($('#add_input').val());
			$('#dyDiv').append("<p>" + searchVar + "</p>");
		});
		$("input[name='float_button']").on('click', function() {
			var searchVar = $.trim($('#float_input').val());
			var text_1 = $.trim($("textarea[name='text_1']").val());
			var text_2 = $.trim($('#text_2').val());
			console.log(searchVar + "---=" + text_1 + "-----=" + text_2);
		});
	});
</script>
</head>
<body>
	<div id="testDiv">
		<input type="text" id="search_input" name="search_content"></input> <br />
		<input type="text" id="read_input" name="read_input" value="    "
			readonly></input> <br /> <input type="button" id="search_button"
			name="search" value="  "></input>
	</div>
	<div id="dyDiv"></div>
	<div id="operDiv">
		<input type="text" id="add_input" name="add_input"></input> <br /> <input
			type="button" id="add_button" name="add_button" value="  "></input>
	</div>
	<input type="text" id="float_input" name="float_input"></input>
	<textarea name="text_1" rows="10" cols="10"></textarea>
	<textarea id="text_2" name="text_2" rows="10" cols="10"></textarea>
	<br />
	<input type="button" name="float_button" value="    "></input>
</body>
</html>

전문이 끝나다.

좋은 웹페이지 즐겨찾기