如何使用jquery访问此属性,给定由此定义的div [英] How to access this attribute using jquery, given a div defined by this
本文介绍了如何使用jquery访问此属性,给定由此定义的div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个通过这个定义的div。假设它是下面的var div:
I have a div which is defined via a this. Imagine it is the var div below:
<td itemid='desired number'>
<div>div 1</div>
<div class="action">div 2</div>
</td>
给定var div,我如何计算包含它的td的itemid属性。注意,我不想要一个直接访问itemid属性的解决方案,它必须包含包含div 2的itemid。
Given the var div how can I work out the itemid attribute of the td which contains it. Note, I do not want a solution which directly accesses the itemid attribute, it has to the itemid which is containing div 2.
var div = $('.action')
。
谢谢。
推荐答案
$ b
Try
var itemidValue = $('.action').parent('td').attr('itemid');
概念验证: http://jsfiddle.net/AwM56/
这篇关于如何使用jquery访问此属性,给定由此定义的div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文