jsp代码:

<span><input type="hidden" value="1" id="newInfo"></input></span>
<div class="sx_title"><a href="#" style="cursor: hand" onclick="more(this);" class="fright mr15">更多</a>英语-其他</div>
<div class="apps_container">
<ul class="apps_list1_1">
<input type="hidden" value="00070008" id="levelCode" />
<input type="hidden" value="100000001811" id="columId" />
<li><a href="/12580SchoolWap/article/getAritcleContent.do?id=100000031133&menuI=6&columnID=100000001811
&sessionid=F881AFC25986F14FEE1DDA60065C565A&levelCode=00070008">
英语作文:The Countryside in Summer
</a>
</li> <input type="hidden" value="00070008" id="levelCode" />
<input type="hidden" value="100000001811" id="columId" />
<li><a href="/12580SchoolWap/article/getAritcleContent.do?id=100000031125&menuI=6&columnID=100000001811
&sessionid=F881AFC25986F14FEE1DDA60065C565A&levelCode=00070008">
英语作文:I Love Summer
</a>
</li>
</ul>
</div>

js代码:

<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>

js代码解释:

当点击 <a 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

jquery获取html中当前元素对象,以及父对象,相邻的上一个对象,或下一个对象的更多相关文章

  1. Js/Jquery获取iframe中的元素

    转载: Js/Jquery获取iframe中的元素 - - ITeye技术网站http://java-my-life.iteye.com/blog/1275205 在web开发中,经常会用到ifram ...

  2. 【学习】如何用jQuery获取iframe中的元素

    (我的博客网站中的原文:http://www.xiaoxianworld.com/archives/292,欢迎遇到的小伙伴常来瞅瞅,给点评论和建议,有错误和不足,也请指出.) 说实在的,以前真的很少 ...

  3. Js/Jquery获取iframe中的元素 在Iframe中获取父窗体的元素方法

    在web开发中,经常会用到iframe,难免会碰到需要在父窗口中使用iframe中的元素.或者在iframe框架中使用父窗口的元素 js 在父窗口中获取iframe中的元素  1. 格式:window ...

  4. jQuery获取标签中的元素

    获取双标签之间的内容 在JavaScript中,获取双标签之间的内容是这样的: <!DOCTYPE html> <html lang="en"> <h ...

  5. Jquery获取iframe中的元素

    iframe与父页面之间相互获取元素的方法: 1.从父页面中获取iframe页面中的元素: 用法: $(window.frames["iframe_include_adverse" ...

  6. js 获取iframe中的元素

    今天要修改编辑器插件中的元素遇到的问题 jquery 在父窗口中获取iframe中的元素 1.Js代码 格式:$("#iframe的ID").contents().find(&qu ...

  7. JQuery获取与设置HTML元素的值value

    JQuery获取与设置HTML元素的值value 作者:简明现代魔法图书馆 发布时间:2011-07-07 10:16:13 20481 次阅读 服务器君一共花费了13.221 ms进行了6次数据库查 ...

  8. 父窗口中获取iframe中的元素

    js 在父窗口中获取iframe中的元素 1. 格式:window.frames["iframe的name值"].document.getElementById("ifr ...

  9. 获取父窗口元素或者获取iframe中的元素(相同域名下)

    jquery方法 在父窗口中获取iframe中的元素 //方法1 $("#iframe的ID").contents().find("iframe中的元素"); ...

随机推荐

  1. git使用——忽略文件

    一般我们总会有些文件无需纳入 Git 的管理,也不希望它们总出现在未跟踪文件列表. 通常都是些自动生成的文件,比如日志文件,或者编译过程中创建的临时文件等.git下有2种方式实现忽略文件的目的.方法一 ...

  2. frp服务搭建

    安装命令 C wget --no-check-certificate https://raw.githubusercontent.com/clangcn/onekey-install-shell/ma ...

  3. webpack中如何编写一个plugin

    loader和plugin有什么区别呢?什么是loader,什么是plugin. 当我们在源代码里面去引入一个新的js文件或者一个其他格式的文件的时候,这个时候,我们可以借助loader去帮我们处理引 ...

  4. SATB深入详解与问题剖析【纯理论】

    延着上一次[https://www.cnblogs.com/webor2006/p/11147893.html]的理论继续. SATB: 在G1中,使用的是SATB(Snapshot-At-The-B ...

  5. python实现查找算法

    搜索是在一个项目集合中找到一个特定项目的算法过程.搜索通常的答案是真的或假的,因为该项目是否存在. 搜索的几种常见方法:顺序查找.二分法查找.二叉树查找.哈希查找 线性查找线性查找就是从头找到尾,直到 ...

  6. linux systemd 从简单的例子入门

    linux systemd 从简单的例子入门 网上很多相关链接,一上来就给一大堆命令和讲解,让人头都大. 我们希望有一个service(服务),让它在开机启动的时候就执行. 用 root 登陆以后: ...

  7. latex 表格每行设置不同字体

    Each cell of a table is set in a box, so that a change of font style (or whatever) only lasts to the ...

  8. SSL 部署,实现 https 化

    HTTPS 请求更安全, 且容易被搜索引擎收录. 现在很多服务器都有免费证书如腾讯云.七牛云.阿里云. 本篇以阿里云为例. 一.申请 SSL 证书 1.登录阿里云服务器: 2.产品与服务 -> ...

  9. 17.组件页面应用和vue项目生成

    基本示例 这里有一个 Vue 组件的示例: // 定义一个名为 button-counter 的新组件 Vue.component('button-counter', { data: function ...

  10. jquery模仿淘宝星星打分

    今天做论坛页面有星星评分功能,以下是代码.用的时候引入jquery <span> <ul class="hs_df_xx"> <li><i ...