티스토리 뷰

개발/Web

jquery 값가져오기

개발자와코더사이가 PM일까? 2013. 1. 17. 23:52
반응형

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>필터</title>
<script type="text/javascript"  src="js/jquery-1.8.3.js"></script>
<script type="text/javascript">
 $(document).ready(function(){
   $("#btn1").click(function(){
    //.val() 선택된 요소의 값을 가져온다.  document.getElementById(“txtName”).value; 와 동일한 역할
   alert("입력하신 값은 첫번째는 " + $("#input1").val());
   alert("입력하신 값은 두번째는 " + $("#input2").val());
   });

   $("#btn2").click(function(){
    //text값은 글자만 html은 모든 html
   alert("text() 값 " + $("#table1").text());
   alert("html() 값" + $("#table1").html());
   });
 });

</script>
</head>
 <body>
  <table>
   <tr id="t2">
    <td ><input id="input1" type="text" /></td>
   </tr>
   <tr id="t1">
    <td><input id="input2" type="text"/></td>
   </tr>
   <tr id="it2">
    <td><input id="btn1" type="button" value="val()값보기"></td>
   </tr>
   <tr id="it3">
    <td><input id="btn2" type="button" value="text()/html() 값보기"></td>
   </tr>
  </table>
  <table id="table1">
   <tr>
    <td>text값테스트를 위한 예제</td>
   </tr>
  </table>
  <table id="table2">
  <tr>
  <td><a href="index.jsp">돌아가기</a></td>
  </tr>
  </table>
 </body>
</html>

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함