본문 바로가기

jQuery

jQuery In Action chapter 1-4

<!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>Radio Group Example</title>
 <link rel="stylesheet" type="text/css" href="../css/core.css">
 <style type="text/css">
 #result tt{
  color: maroon;
  font-size: 1.1em;
 }
 form>div{
  margin-top: 0.9em;
 }
 </style>
 <script type="text/javascript" src="../js/jquery-1.3.2.min.js" ></script>
 <script type="text/javascript">
 $(function () {
  $('#testButton').click(function () {
   var checkedValue = $('[name=someRadioGroup]:radio:checked').val();
   $('#result').html('The radio element with value <tt>' + checkedValue + '<tt> is checked.');
  });
 });
 </script>
</head>
<body>
 <form>
  <div>
   <label for="radioYes">What is your answer?</label>
   <input type="radio" name="someRadioGroup" id="radioYes" value="yes" checked="checked" /> Yes
   <input type="radio" name="someRadioGroup" id="radioNo" value="no" />No
   <input type="radio" name="someRadioGroup" id="radioMaybe" value="maybe" />Maybe
   <input type="radio" name="someRadioGroup" id="radioConfused" value="confused" />I dunno
  </div>
  <div><button type="button" id="testButton" class="green90x24">Which?</button></div>
  <div id="result"></div>
 </form>
</body>
</html>

'jQuery' 카테고리의 다른 글

jQuery selector  (0) 2009.12.19
jQuery In Action chapter2-1  (0) 2009.12.19
jQuery In Action chapter 1-3  (0) 2009.12.19
jQuery In Action chapter 1-2  (0) 2009.12.19
jQuery In Action chapter1-1  (0) 2009.12.19