jQuery在自我中开始搜索 [英] Jquery start search in self

查看:97
本文介绍了jQuery在自我中开始搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用以下方法:

var element = $('#Adiv').find('[name="thename"]');

这将在Adiv中搜索名称为"thename"的元素. 但是Adiv也可以使用名称"thename",因此应首先查看其自己的名称. 我该怎么做呢?我尝试了andSelf(),但是即使没有正确的名称,它也只包含整个元素.

This searches in Adiv for an element with the name 'thename'. But Adiv could also have the name 'thename', so it should first look at its own name. How do I do this? I tried andSelf(), but that just includes the entire element even if it doesn't have the right name.

推荐答案

您可以执行以下操作:

var element = $('#Adiv').parent().find('[name="thename"]');

这篇关于jQuery在自我中开始搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆