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. 解决mysql登录警告问题

    一.前言 我们在登录mysql的时候经常会看到一句警告: Warning: Using a password on the command line interface can be insecure ...

  2. nginx的应用【静态代理、动静分离】

    Nginx主要应用: 静态web服务器 负载均衡 静态代理虚拟主机 静态代理 :把所有静态资源的访问改为访问nginx,而不是访问tomcat,因为nginx更擅长于静态资源的处理,性能更好,效率更高 ...

  3. Robot Framework--Scalar变量

    一.变量赋值 1)Set赋值 通常使用Set Variable关键字对变量进行赋值,其他Set相关的带Variable的关键字也可以进行赋值 赋值的时候,变量后面写不写『=』都可以,如下: 如果${v ...

  4. LevelDB的源码阅读(三) Get操作

    在Linux上leveldb的安装和使用中我们写了这么一段测试代码,内容以及输出结果如下: #include <iostream> #include <string> #inc ...

  5. 2019-2020-1 20199312《Linux内核原理与分析》第四周作业

    计算机和操作系统的法宝 计算机三个法宝 存储程序计算机.函数调用堆栈机制.中断 操作系统:中断中断上下文的切换--保护和恢复现场 进程上下文的切换. Linux源代码目录分析 arch目录:代码量庞大 ...

  6. Sql Server (MSSQLSERVER) 服务无法启动

    北京的冬天特别干燥,大清早的一同事就和服务器擦出了爱的火花,结果没想到竟导致服务器无法开机了,这可尴尬了,代码可都在服务器上托管着呢,一会还等着上线呢,必须得修啊.他们说是主板坏了,就另外找了一台电脑 ...

  7. 48、[源码]-Spring容器创建-初始化事件派发器、监听器等

    48.[源码]-Spring容器创建-初始化事件派发器.监听器等 8.initApplicationEventMulticaster();初始化事件派发器: 获取BeanFactory 从BeanFa ...

  8. Convert AS400 Spool to PFD Tools – PDFing

    1. Steps There’s a tool PDFing convert spool file to PDF with simple way. No need install AS400 obje ...

  9. css选择器:first-child与:first-of-type的区别

    :first-child选择器是css2中定义的选择器,从字面意思上来看也很好理解,就是第一个子元素.比如有段代码: <div> <p>第一个子元素</p> < ...

  10. P3038 [USACO11DEC]牧草种植Grass Planting

    题目描述 Farmer John has N barren pastures (2 <= N <= 100,000) connected by N-1 bidirectional road ...