jquery获取元素的值,获取当前对象的父对象等等
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获取元素的值,获取当前对象的父对象等等的更多相关文章
- [转载]jquery获取元素索引值index()方法:
jquery的index()方法 搜索匹配的元素,并返回相应元素的索引值,从0开始计数. 如果不给 .index() 方法传递参数,那么返回值就是这个jQuery对象集合中第一个元素相对于其同辈元素的 ...
- jquery获取元素索引值index()方法
jquery的index()方法 搜索匹配的元素,并返回相应元素的索引值,从0开始计数. 如果不给 .index() 方法传递参数,那么返回值就是这个jQuery对象集合中第一个元素相对于其同辈元素的 ...
- jquery获取元素索引值index()
jquery获取元素索引值index()方法实例. jquery获取元素索引值index()方法: jquery的index()方法 搜索匹配的元素,并返回相应元素的索引值,从0开始计数. 如果不给 ...
- jquery获取元素索引值index()的例子
如果参数是一组DOM元素或者jQuery对象,那么返回值就是传递的元素相对于原先集合的位置. 如果参数是一个选择器,那么返回值就是原先元素相对于选择器匹配元素中的位置.如果找不到匹配的元素,则返回-1 ...
- 转贴:获取元素CSS值之getComputedStyle方法熟悉
获取元素CSS值之getComputedStyle方法熟悉 一.碎碎念~前言 我们都用过jQuery的CSS()方法,其底层运作就应用了getComputedStyle以及getPropertyVal ...
- Js获取元素样式值(getComputedStyle¤tStyle)兼容性解决方案
因为:style(document.getElementById(id).style.XXX)只能获取元素的内联样式,内部样式和外部样式使用style是获取不到的. 一般js获取内部样式和外部样式使用 ...
- JS获取元素CSS值的各种方法分析
先来看一个实例:如何获取一个没有设置大小的字体? <!DOCTYPE html> <html lang="en"> <head> <met ...
- 获取元素CSS值之getComputedStyle方法熟悉
by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=2378 一.碎碎念~前 ...
- getComputedStyle方法获取元素CSS值
javascript的style属性只能获取内联样式,对于外部样式和嵌入式样式需要用currentStyle属性.但是,currentStyle在FIrefox和Chrome下不支持,需要用getCo ...
随机推荐
- JDBC学习笔记(1)
说明:本系列学习笔记主要是学习传智播客的李勇老师的教学课程和一本英文电子书<JDBC Recipes A Problem-Solution Approach>所作的笔记. 1,什么是JDB ...
- github 仓库管理
一.远程仓库有master和dev分支1. 克隆代码 git clone https://github.com/master-dev.git # 这个git路径是无效的,示例而已 2. 查看所有分支 ...
- iOS 图片压缩
+ (UIImage *)scaleFromImage:(UIImage *)image { CGSize newSize = CGSizeMake(366, 366); //目标图片的大小 ...
- SQL到NOSQL的思维转变
NOSQL系统一般都会宣传一个特性,那就是性能好,然后为什么呢?关系型数据库发展了这么多年,各种优化工作已经做得很深了,NOSQL系统一般都是吸收关系型数据库的技术,然后,到底是什么因素束缚了关系型数 ...
- Largest Rectangle in a Histogram(HDU1506)
Largest Rectangle in a Histogram HDU1506 一道DP题: 思路:http://blog.csdn.net/qiqijianglu/article/details/ ...
- Mono、Unity和Xamarin三者关系
1.Mono: .net是微软出的标准.如果站在Mono的角度来说,这套标准能规定编译器产生一些符合一定条件的文件出来,这些中间文件最后在目标平台上被解析成跟机器相关的东西.问题是,开始只有Windo ...
- C#设计模式(18)——中介者模式(Mediator Pattern)
一.引言 在现实生活中,有很多中介者模式的身影,例如QQ游戏平台,聊天室.QQ群和短信平台,这些都是中介者模式在现实生活中的应用,下面就具体分享下我对中介者模式的理解. 二. 中介者模式的介绍 2.1 ...
- JS学习笔记12_优化
一.可维护性优化 1.添加注释 注释能够增强代码的可读性以及可维护性,当然,理想情况是满满的注释,但这不太现实.所以我们只需要在一些关键的地方添上注释: 函数和方法:尤其是返回值,因为直接看不出来 大 ...
- node-webkit教程(10)Platform Service之File dialogs
node-webkit教程(10)Platform Service之File dialogs 文/玄魂 目录 node-webkit教程(10)Platform Service之File dialog ...
- [自娱自乐] 2、超声波测距模块DIY笔记(二)
前言 上一节我们已经大致浏览下目前销售的超声波测距模块同时设计了自己的分析电路,这次由于我买的电子元件都到了,所以就动手实验了下!至写该笔记时已经设计出超声波接收模块和超声波发射模块,同时存在超声波发 ...