我正在尝试将alt值添加到特定div中的所有锚标记。 我需要遍历div并找到锚标记并添加alt值。 结构如下所示
<div id="ctl00_MenuTreeView" style="font-size:11px;" onadaptedselectednodechanged="OnNodeSelected">
<table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody>
<tr>
<td>
<td class="TreeViewNode ctl00_MenuTreeView_2 ctl00_MenuTreeView_6" onmouseout="TreeView_UnhoverNode(this)" onmouseover="TreeView_HoverNode(ctl00_MenuTreeView_Data, this)">
<a id="ctl00_MenuTreeViewt0" class="ctl00_MenuTreeView_0 TreeViewNode ctl00_MenuTreeView_1 ctl00_MenuTreeView_5" style="border-style:none;font-size:1em;" title="Home Page" onclick="TreeView_SelectNode(ctl00_MenuTreeView_Data, this,'ctl00_MenuTreeViewt0');" href="javascript:__doPostBack('ctl00$MenuTreeView','s/wotc/Default.aspx')">Home</a>
</td>
</tr>
</tbody>
</table>
<table cellspacing="0" cellpadding="0" style="border-width:0;">
<table cellspacing="0" cellpadding="0" style="border-width:0;">
<table cellspacing="0" cellpadding="0" style="border-width:0;">
<table cellspacing="0" cellpadding="0" style="border-width:0;">
</div>
感谢 亚历
答案 0 :(得分:0)
function OnTreeViewLoaded() {
$('#ctl00_MenuTreeView .TreeViewNode a').attr('alt', 'whatever');
}