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获取元素的值,获取当前对象的父对象等等的更多相关文章

  1. [转载]jquery获取元素索引值index()方法:

    jquery的index()方法 搜索匹配的元素,并返回相应元素的索引值,从0开始计数. 如果不给 .index() 方法传递参数,那么返回值就是这个jQuery对象集合中第一个元素相对于其同辈元素的 ...

  2. jquery获取元素索引值index()方法

    jquery的index()方法 搜索匹配的元素,并返回相应元素的索引值,从0开始计数. 如果不给 .index() 方法传递参数,那么返回值就是这个jQuery对象集合中第一个元素相对于其同辈元素的 ...

  3. jquery获取元素索引值index()

    jquery获取元素索引值index()方法实例. jquery获取元素索引值index()方法: jquery的index()方法 搜索匹配的元素,并返回相应元素的索引值,从0开始计数. 如果不给 ...

  4. jquery获取元素索引值index()的例子

    如果参数是一组DOM元素或者jQuery对象,那么返回值就是传递的元素相对于原先集合的位置. 如果参数是一个选择器,那么返回值就是原先元素相对于选择器匹配元素中的位置.如果找不到匹配的元素,则返回-1 ...

  5. 转贴:获取元素CSS值之getComputedStyle方法熟悉

    获取元素CSS值之getComputedStyle方法熟悉 一.碎碎念~前言 我们都用过jQuery的CSS()方法,其底层运作就应用了getComputedStyle以及getPropertyVal ...

  6. Js获取元素样式值(getComputedStyle&currentStyle)兼容性解决方案

    因为:style(document.getElementById(id).style.XXX)只能获取元素的内联样式,内部样式和外部样式使用style是获取不到的. 一般js获取内部样式和外部样式使用 ...

  7. JS获取元素CSS值的各种方法分析

    先来看一个实例:如何获取一个没有设置大小的字体? <!DOCTYPE html> <html lang="en"> <head> <met ...

  8. 获取元素CSS值之getComputedStyle方法熟悉

    by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=2378 一.碎碎念~前 ...

  9. getComputedStyle方法获取元素CSS值

    javascript的style属性只能获取内联样式,对于外部样式和嵌入式样式需要用currentStyle属性.但是,currentStyle在FIrefox和Chrome下不支持,需要用getCo ...

随机推荐

  1. 冒泡排序优化JAVA

    本文对传统的冒泡排序进行了一些优化,减少了循环次数. 时间复杂度 若文件的初始状态是正序的,一趟扫描即可完成排序.所需的关键字比较次数 C 和记录移动次数 M 均达到最小值: C(min)=n-1 , ...

  2. C#开发中使用Npoi操作excel实例代码

    C#开发中使用Npoi操作excel实例代码 出处:西西整理 作者:西西 日期:2012/11/16 9:35:50 [大 中 小] 评论: 0 | 我要发表看法 Npoi 是什么? 1.整个Exce ...

  3. 微信JSSDK多图片上传并且解决IOS系统上传一直加载的问题

    微信多图片上传必须挨个上传,也就是不能并行,得串行: 那么我们可以定义一个如下所示的上传函数: var serverIds = []; function uploadImages(localImage ...

  4. [转发]UML类图符号 各种关系说明以及举例

    UML中描述对象和类之间相互关系的方式包括:依赖(Dependency),关联(Association),聚合(Aggregation),组合(Composition),泛化(Generalizati ...

  5. windowsXP用户被禁用导致不能网站登录

    1.查看系统事件,发现弹出如下的错误 2.根据上面的错误,我们很容易就可以判断是禁用了账户引起的 2.1后面进入计算机管理,再进入用户管理 2.2双击点开Internet来宾用于,发现此用户已经停用了 ...

  6. 【转】关于KDD Cup '99 数据集的警告,希望从事相关工作的伙伴注意

    Features From: Terry Brugger Date: 15 Sep 2007 Subject: KDD Cup '99 dataset (Network Intrusion) cons ...

  7. CentOS7 修改系统时间

    yum -y install ntp [root@localhost kevin]# systemctl enable ntpdsystemctl start ntpdntpdate us.pool. ...

  8. django with mysql (part-1)

    step01: django-admin.py startproject dj01 step02: cd dj01 tree step03: python manage.py runserver Th ...

  9. Atitit. 解压缩zip文件 的实现最佳实践 java c# .net php

    Atitit. 解压缩zip文件 的实现最佳实践 java c# .net php 1. Jdk zip 跟apache ant zip 1 2. Apache Ant包进行ZIP文件压缩,upzip ...

  10. [轻微]WEB服务器启用了OPTIONS方法/如何禁止DELETE,PUT,OPTIONS等协议访问应用程序/tomcat下禁用不安全的http方法

    使用了360网站安全检测 查到有OPTIONS方法 百度了下 https://my.oschina.net/maliang0130/blog/338725 找到这个方法奈何http.conf 找不到无 ...