<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="ja" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="imagetoolbar" content="no" /> <title>DOM要素の属性(Attirbutes):クラス(Class):removeClass([class])の使用例 | jQuery</title> <link rel="stylesheet" type="text/css" href="/content/lib/global.css" /> <!-- JS --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript"> $(function(){ $("#btn_addclass").click(function(){ /* boxクラス追加 */ $("#sample").addClass("box"); }); $("#btn_removeclass").click(function(){ /* boxクラス削除 */ $("#sample").removeClass("box"); }); }); </script> <style type="text/css"> .box { background:#000; color:#fff; width:350px; padding:10px; clear:both; } .box a { width:75px; height:75px; float:left; margin-right:10px } </style> <link rel="stylesheet" type="text/css" href="/common/css/example.css"></head> <body id='example3' class='example'><div class="ads" style="margin:32px auto;text-align:center;"></div><h1 class='h'><a href='/'>PHP & JavaScript Room</a> :: 設置サンプル</h1> <h3 class='h'>実行結果</h3> <div id="wrap"> <h1>DOM要素の属性(Attirbutes):クラス(Class):removeClass([class])の使用例 | jQuery</h1> <!-- CODE --> <p> <button id="btn_addclass">boxクラス追加</button> <button id="btn_removeclass">boxクラス削除</button> </p> <div id="sample" class="cf"> <a href="http://www.flickr.com/photos/22559849@N06/2974008614/"><img src="http://farm4.static.flickr.com/3222/2974008614_736e2d5b50_s.jpg" width="75" height="75" alt="くまさんケーキ" /></a> むにゅっとした顔がちょっとムカつく、くまの顔をしたケーキ。新宿アルタの地下で見かけて思わず激写!どこから食べようか考えちゃうよね。とりあえず耳からいっておきますかw </div> <!-- CODE / --> </div> </body> </html>