給表格式按鈕邊框點擊變色--css製作表格式按鈕(2)

來源:互聯網
上載者:User

  這邊先給出製作樣式:

  這邊想對每個按鈕在點擊的邊框改變樣式,用each和click的結合實現最好不過,上jquery代碼:

     $("#filterMenu a").each(function () {            //this.id = i;// 設定每個a標籤的id為自增id            //i++;            $(this).click(function () {                // 設定每個a標籤的onclick事件                //alert(this.id);                if ($(this).hasClass("SwitchColor"))                    $(this).removeClass("SwitchColor");                else {                    $("#filterMenu a").each(function () {                        $(this).removeClass("SwitchColor");                    });                    $(this).addClass("SwitchColor");                }            });        });
樣式只要提供多一個SwitchColor為:

 .SwitchColor {                   outline: 1px solid #ff4400;                }

其他的和之前寫的第一篇css製作表格式按鈕一樣的html:

  <!--write filtMenu here-->        <div id="filterMenu">            <div class="content">                <div class="filter Left">            <a id="all" class="filterButton"><span>全部<span class="filterButtonNumber">(30)</span></span></a>            <a id="bondType" class="filterButton"><span>債券型<span  class="filterButtonNumber">(30)</span></span></a>             <a id="setToOpen"  class="filterButton"><span>定開債<span  class="filterButtonNumber">(30)</span></span></a>            </div>            <div class="filter Middle">            <a id="stockType" class="filterButton "><span>股票型<span  class="filterButtonNumber">(30)</span></span></a>            <a id="QDIIType" class="filterButton"><span>QDII<span  class="filterButtonNumber">(30)</span></span></a>            </div>            <div class="filter Right">            <a id="hybridType" class="filterButton "><span>混合型<span  class="filterButtonNumber">(30)</span></span></a>            <a id="breakevenType" class="filterButton"><span>保本型<span  class="filterButtonNumber">(30)</span></span></a>            </div>                </div>        </div>



相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.