jQuery日本語リファレンス

jQuery does not mean Japanese Query...

Core/API/jQuery - Sample Code

jQuery.fn.extend(object)


	        
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <script src="/jquery/js/jquery.js"></script>
  <script>
  jQuery.fn.extend({
    check: function(){
      return this.each(function(){this.checked=true;});
    },
    uncheck: function(){
      return this.each(function(){this.checked=false;});
    }
  });
  $(document).ready(function(){
    $("#check-all").click(function(){
      $("input[@type=checkbox]").check();
    });
    $("#uncheck-all").click(function(){
      $("input[@type=radio]").uncheck();
    });
  });
  </script>
<body>
<form>
<div>
<input type="button" id="check-all" value="check all" />
<input type="checkbox" />
<input type="checkbox" />
<input type="checkbox" />
<input type="checkbox" />
</div>
<div>
<input type="button" id="uncheck-all" value="uncheck all" />
<input type="radio" name="r1" />
<input type="radio" name="r1" />
<input type="radio" name="r1" />
<input type="radio" name="r1" />
</div>
</form>
</body>
</html>
            
	      
[実行結果]
[jQuery.fn.extend(object) の説明へ]