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>

  • 相关阅读:
    桥接模式(Bridge)
    Python中文件操作
    Python中字符的编码与解码
    反转部分单向链表
    删除链表的中间节点和a/b处的节点
    链表中删除倒数第K个节点
    如何实现链表的逆序
    Python高阶函数及函数柯里化
    Python函数作用域
    Python函数参数与参数解构
  • 原文地址:https://www.cnblogs.com/lemon863376328/p/4969096.html
Copyright © 2011-2022 走看看