zoukankan      html  css  js  c++  java
  • jsp 页面通过jq处理默认 选中的项 数据是通过遍历显示

     jsp页面循环显示里面是<a></a>或者<input>  id 以什么开头的id,然后当你点击那个的时候就在那个上面添加样式

    <div>

    <div class="serviceLeft floatL">

             <!-- 选中颜色样式 mianColor -->

             <!-- <div id="" class="text-align-center"><a href="#" class="mianColor">知识产权</a></div> -->

    <c:forEach items="${slist }" var="s">

             <div class="text-align-center">

    <a href="#"id="choice_${s.id }">${s.supportingname } </a>

    </div>

    </c:forEach>对应的标签类型

    </div>

    <script type="text/javascript">

             $(document).ready(function(){

                       $("a[id^='choice_']").each(function () {

                       $("a[id^='choice_']:first").attr("class","mianColor");   ----à默认选中第一个

                       $(this).bind(“click”, function () {

                                $(“a[id^=’choice_’]”).each(function () {

                                         $(this).removeAttr(“class”);-------------à去掉样式

                                         });

                                $(this).attr("class","mianColor");----------------à添加样式

                                });

                       });              

             });

    </script>

  • 相关阅读:
    求职简历撰写要点和模板分享
    find命令
    MD5Init-MD5Update-MD5Final
    Linux find命令详解
    Linux进程KILL不掉的原因
    Linux操作系统的内存使用方法详细解析
    Lsof命令详解
    为什么ps中CPU占用率会有超出%100的现象?
    第12课 经典问题解析一
    第11课 新型的类型转换
  • 原文地址:https://www.cnblogs.com/lemon863376328/p/4969096.html
Copyright © 2011-2022 走看看