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. C#导出和导入Excel模板功能

    引用  Aspose.Cells; 基于WinForm 导入 private void btn_excel_input_Click(object sender, EventArgs e) { try ...

  2. Mysql 中的SSL 连接

    Mysql 中的SSL 连接 以下来自网络参考和自己测试整理,没有查找相关资料.若有错误之处,欢迎指正. 当前的Mysql 客户端版本基本都不太能支持 caching_sha2_password 认证 ...

  3. Linux 之 压缩解压缩

    Linux中常见的压缩格式 .zip            .gz             .bz2           .tar.gz      tar.bz2 zip zip格式的压缩文件和win ...

  4. 前端HTML基础和head部分

    一.SOCKET服务器与浏览器交互 CS模式 -->  BS模式 CS模式逐渐向BS模式转移,底层都是socket客户端 浏览器给服务器发送请求 --> 服务器收到请求 --> 服务 ...

  5. lua游戏开发易错踩坑录

    一.local local函数一定要在调用之前定义(切记,不然会报错或者不能调用该函数) 情况1:监听调此函数后定义 base.model:addlistener("被监听的函数" ...

  6. 【CRT】中国剩余定理简介

    中国剩余定理(CRT) 中国剩余定理出自中国的某本古书,似乎是孙子兵法?(雾 其中有这样一个问题: 有物不知其数,三三数之剩二,五五数之剩三,七七数之剩二.问物几何? 即,对于这样一个方程组: \[ ...

  7. Spring Boot源码探索——自动配置的内部实现

    前面写了两篇文章 <Spring Boot自动配置的魔法是怎么实现的>和 <Spring Boot起步依赖:定制starter>,分别分析了Spring Boot的自动配置和起 ...

  8. springboot中用来进行查看错误日志的logback文件

    <?xml version="1.0" encoding="UTF-8"?> <!-- 从高到地低 OFF . FATAL . ERROR . ...

  9. flask 杂记3

    SQLAlchemy在模型之间建立关系模式:  https://www.bbsmax.com/A/mo5k7gKn5w/ 一对多时:外键只能存储单一数据(标量),所以外键总是在“多”这一侧定义,多篇文 ...

  10. Coins in a Line II

    There are n coins with different value in a line. Two players take turns to take one or two coins fr ...