Javascript 查找控件的父级(),然后查找(";a";)JQuery

Javascript 查找控件的父级(),然后查找(";a";)JQuery,javascript,jquery,Javascript,Jquery,我有一个,看起来像这样: <td class="myTDClass"> <span class="spanClass">Header</span> <br /> <img class='myImages' style='cursor: hand;' onclick='doSomething(control)' alt='this is my alt Text'></img> <br /&

我有一个
,看起来像这样:

<td class="myTDClass">
    <span class="spanClass">Header</span>
    <br />
    <img class='myImages' style='cursor: hand;' onclick='doSomething(control)' alt='this is my alt Text'></img>
    <br />
    <span style="color: #123456;">More Text</span>
    <br />
    <a class='findThisClass'>Insert Alt Text Here</a>
</td>
jQuery代码将alt标记设置得很好,但找不到

我想我使用的
.parent()
.siblines()
是错误的。有人能发现我的错误吗?这里的想法是,我可以只在
中搜索
元素,而不接触其他
中的其他元素

var $newControl = $(control).closest('.myTDClass').find(".findThisClass");
alert($newControl.text());
另外,
img
是自动关闭标签,而不是:

<img></img>
onclick='doSomething(control)'
使用:

因此jQuery确实有一个控件可以使用:)


假设要查找与
位于同一表单元格中的
,则不需要使用
parent()
。您只需呼叫
。兄弟姐妹
试试:

var $newControl = $(control).siblings('a.findThisClass').first();

这假设
control
指向表单元格中的图像。

a
是图像的同级,因此:

$("a.findThisClass", $myControl).first()
$(control).siblings(".findThisClass")

为什么需要
.parent()
的兄弟姐妹。尝试从
$newControl
中取出
parent()
,看看会发生什么?你的意思是
光标:指针
?@Rocket
cursor:hand
是MSIE某处的一种特殊光标样式=<6.BTW,在
onclick
中作为
doSomething
参数的
控件是什么?
var $newControl = $(control).siblings('a.findThisClass').first();
$("a.findThisClass", $myControl).first()
$(control).siblings(".findThisClass")