我需要编写jquery,删除锚标记属性,并添加其他属性...我不能在html中进行直接更改,所以必须通过jquery来完成。我该怎么办?
<span id="TabnavTabLogoTextId" class="navTabButton navTabThemeButton" title="Microsoft Dynamics CRM Go to home page.">
<a title="Microsoft Dynamics CRM Go to home page." class="navTabButtonLink" onkeypress="return true;" onclick="return false;" href="javascript:;" unselectable="on">
<span id="navTabLogoTextId" class="navTabLogoTextThemeImage">
<img alt="Microsoft Dynamics CRM Microsoft Dynamics CRM" unselectable="on" src="/NFDIL/%7B636004438060001088%7D/WebResources/pcl_SiteLogo.png">
</span>
</a>
</span>
答案 0 :(得分:1)
使用removeAttr
删除锚点的所有属性。
$('a').removeAttr('title,class,onkeypress,onclick,href,unselectable');
如果要将属性添加回<a>
$('a').attr('title','//yourtitle'); // and so on like this