PHP & JavaScript Room :: 設置サンプル

実行結果

Exactly Twitter like Follow and Remove buttons with jQuery and Ajax | 設置サンプル

User A
User B
User C

設置サンプルのソース

<!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>Exactly Twitter like Follow and Remove buttons with jQuery and Ajax | 設置サンプル</title>
      <link rel="stylesheet" type="text/css" href="/content/lib/global.css" />
         <!-- JS -->
      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
      <script type="text/javascript">
         $(function() {
            $(".follow").click(
               function(){
               var element = $(this);
               var I = element.attr("id");
               var info = 'id=' + I;
               $.ajax({
                  type: "POST",
                  url: "ajaxfollow.tix",
                  data: info,
                  success: function(){}
               });
               $("#follow"+I).fadeOut(200).hide();
               $("#remove"+I).fadeIn(200).show();
               return false;
            });
            $(".remove").click(function(){
               var element = $(this);
               var I = element.attr("id");
               var info = 'id=' + I;
               $.ajax({
                  type: "POST",
                  url: "ajaxfollow.tix",
                  data: info,
                  success: function(){}
               });
               $("#remove"+I).fadeOut(200).hide();
               $("#follow"+I).fadeIn(200).show();
               return false;
            });
         });
         </script>
         <!-- CSS -->
      <style type="text/css">
         a {
            text-decoration:none;
         }
         table {
            width:455px;
            border:0;
            border-collapse:collapse;
            border-spacing:0;
            background-color:#fff;
         }
         th,
         td {
            padding:10px;
         }
         td.icon {
            width:32px;
            border-bottom:1px dashed #ccc;
         }
         .content {
            border-bottom:1px dashed #ccc;
            background-color:#fff;
         }
         .follow_b {
            border:#dedede solid 2px;
            background-color:#f5f5f5;
            color:#000;
            font-size:12px;
            font-weight:bold;
            padding-left:4px ;
            padding-right:4px ;
            -moz-border-radius: 6px; -webkit-border-radius: 6px; 
         }
         .youfollowing_b {
            font-size:10px; color:#006600; font-weight:bold;
         }
         .remove_b {
            border:#dedede solid 2px;
            background-color:#f5f5f5;
            color:#CC3333;
            font-size:12px;
            padding-left:4px ;
            padding-right:4px ;
            font-weight:bold;
            margin-left:280px;
            -moz-border-radius: 6px;
            -webkit-border-radius: 6px; 
         }
      </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 &amp; JavaScript Room</a> :: 設置サンプル</h1>
<h3 class='h'>実行結果</h3>
      <div id="wrap">
         <h1><a href='http://9lessons.blogspot.com/2009/04/exactly-twitter-like-follow-and-remove.html'>Exactly Twitter like Follow and Remove buttons with jQuery and Ajax</a> | 設置サンプル</h1>
<!-- CODE -->
<table>
   <tr class="record">
      <td class="icon"><img src="/content/img/picon/twitter.png" width="32" height="32" /></td>
      <td class="content">
         <strong>User A</strong>
         <div id="follow1"><a href="#" class="follow" id="1"><span class="follow_b">フォローする</span></a></div>
         <div id="remove1" style="display:none">
            <span class="youfollowing_b">フォロー中</span>
            <a href="" class="remove" id="1"><span class="remove_b">削除</span></a>
         </div>
      </td>
   </tr>
   <tr class="record">
      <td class="icon"><img src="/content/img/picon/twitter.png" width="32" height="32" /></td>
      <td class="content">
         <strong>User B</strong>
         <div id="follow2"><a href="#" class="follow" id="2"><span class="follow_b">フォローする</span></a></div>
         <div id="remove2" style="display:none">
            <span class="youfollowing_b">フォロー中</span>
            <a href="" class="remove" id="2"><span class="remove_b">削除</span></a>
         </div>
      </td>
   </tr>
   <tr class="record">
      <td class="icon"><img src="/content/img/picon/twitter.png" width="32" height="32" /></td>
      <td class="content">
         <strong>User C</strong>
         <div id="follow3"><a href="#" class="follow" id="3"><span class="follow_b"> フォローする </span></a></div>
         <div id="remove3" style="display:none">
            <span class="youfollowing_b"> フォロー中 </span>
            <a href="" class="remove" id="3"><span class="remove_b">削除</span></a>
         </div>
      </td>
   </tr>
</table>
<!-- / CODE -->
      </div>
   </body>
</html>