猿问

遍历某DIV下所有li,并在每个子li点击时触发此DIV的样式修改

如题,我是这样写的,不知道哪里不对,请帮忙调下,谢谢!

 <script>
   window.onload=function(){
     var divs =  document.getElementsByTagName("#col-lg-2");
    $("#dd-item").onclik(function()
            {divs.style.csstext='width: 25%; height:100%; position:fixed; top:350px; overflow-y:3px;'}) 
        }
 </script>      

 <div id="col-lg-2" class="col-lg-2" style="width: 25%">
  <ol class="dd-list">
                                    <li class="dd-item" data-id="1">
                                        <div class="dd-handle" id="li_Preliminary_Analysis">初步分析</div>
                                    </li>
                                    <li class="dd-item" data-id="2">
                                        <div class="dd-handle" id="li_Early_Disposal">先期处置</div>
                                    </li>
                                    <li class="dd-item" data-id="3">
                                        <div class="dd-handle" id="li_Middle_Disposal">中期处置</div>
                                                                                                        
                                                                                                        
                                                         </li>
                                </ol>
                                </div>

最好能将具体调整代码示范,不做过多设置


红糖糍粑
浏览 1221回答 9
9回答

qq_笑_17

你用的getElementsByTagName函数传入的参数应该是标签名,但是你写的却是id,获取所有li应该是这么写吧:var&nbsp;divs&nbsp;=&nbsp;&nbsp;document.getElementsByTagName("li");

浮云间

用下jquery库可能实现js功能会更简单

繁星点点滴滴

如果你是JS和JQ还不能分辨太清就先写JS差不多了在用JQ写(单独的JQ),两个都差不多了在试着混用看看自己能否运用自如是否对这两个的理解透

慕哥6287543

1 2 3 4<script&nbsp;type="text/javascript"> &nbsp;&nbsp;&nbsp;&nbsp;$('#propertyli').live('click',&nbsp;function()&nbsp;{ 里面是li的单机事件需要执行的任务。 $('#propertyId').arr('background','#efefef'); &nbsp;&nbsp;&nbsp;&nbsp;}); </script>
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答