zoukankan      html  css  js  c++  java
  • jquery 点击当前input元素对象获取下一个input对象

       

    • <div class="apps_container">  
    •    
    •         <input type="hidden" value="00070008"  onclick="more(this);" />  
    •         <input type="hidden" value="100000001811" id="columId" />  
    •      
    • </div>  
    • <script>  
    •  function more(thisObj ){      
    •      var levelCode=$(thisObj).parent().next().children("ul").children("input").eq(0).val();      
    •      var menuI = $("#menuI").val();  
    •      var newInfo = $(thisObj).parent().prev().children("input").eq(0).val();  
    •       if(newInfo && newInfo=='1'){  
    •           menuI=1;   
    •       }  
    •      var columId=$(thisObj).parent().next().children("ul").children("input").eq(1).val();  
    •      url="/12580SchoolWap/article/getCmsModuleList.do?levelCode="+levelCode+"&columnID="+ columId+"&menuI="+menuI;  
    •     document.location=url;  
    • }  
    • </script>  
    • 当点击 <href="#" style="cursor: hand" onclick="more(this);" class="fright mr15">更多</a>时,  
    • 在js的函数中想要获取隐藏域的值  
    • <input type="hidden" value="00070008" id="levelCode" />  
    • <input type="hidden" value="100000001811" id="columId" />  
    •   
    • onclick="more(this);"这里的this 指的是当前dom元素  <a></a>标签  
    •   
    • 在js的函数function more(thisObj){...}中,  
    • 1.$(thisObj)获取<a></a>的jquery对象,  
    • 2.$(thisObj).parent(),获取到<a></a>的父对象<div class="sx_title">...</div>  
    • 3.$(thisObj).parent().next() 获取到<div class="apps_container">jquery对象  
    • 4.$(thisObj).parent().next().children("ul") 获取到<ul class="apps_list1_1">jquery对象  
    • 5.$(thisObj).parent().next().children("ul").children("input").eq(0)  
    • 获取到<ul class="apps_list1_1">下面的第一个<input>元素:<input type="hidden" value="00070008" id="levelCode" />  
    • 6.$(thisObj).parent().next().children("ul").children("input").eq(0).val();  
    • 获取到<input type="hidden" value="00070008" id="levelCode" />的value值 :00070008  
    • 7.$(thisObj).parent().next().children("ul").children("input").eq(1).val();  
    • 获取到<ul class="apps_list1_1">下面的第二个<input>元素,  
    • <input type="hidden" value="100000001811" id="columId" />的值:100000001811  
    • 8.$(thisObj).parent().prev()获取到<span></span>jquery对象  
    • 9.$(thisObj).parent().prev().html()获取到<span></span>的内容<input type="hidden" value="1" id="newInfo"></input>  
    • 10.$(thisObj).parent().prev().children("input").eq(0).val()获取  
    • <span></span>下面的第一个<input>的值,其实就一个<input>元素,即:1  
  • 相关阅读:
    CSS3笔记
    HTML5新标签
    前端工程师面试题JavaScript部分(第五季)
    前端工程师面试题JavaScript部分(第四季)
    前端工程师面试题JavaScript部分(第三季)
    前端组件开发方式(二)
    前端组件开发方式(一)
    面向对象的代码研究(一)
    ServiceDemo,ClientDemo Socket chat
    Socket(java基础)
  • 原文地址:https://www.cnblogs.com/Strugglehard/p/6672782.html
Copyright © 2011-2022 走看看