鼠标悬停在jquery中的元素

时间:2012-08-21 09:53:31

标签: javascript jquery

我有这样的HTML代码:

<div class="tree-node" node-id="71408acd-931e-42c8-98fa-393271006cf9" style="cursor: pointer;">
<span class="tree-hit tree-collapsed"></span>
<span class="tree-icon tree-folder icon-hospital"></span>
<span class="tree-checkbox tree-checkbox1"></span>
<span class="tree-title">
<a href="/Structure/EditHospital/71408acd-931e-42c8-98fa-393271006cf9">Hospital1</a>
(1/1)
</span>
</div>

我想在鼠标悬停此元素时更改光标,如果pointer constainse <span class="tree-title">a href则显示default,如果没有,则显示{{1}}。

1 个答案:

答案 0 :(得分:3)

$('.tree-title').each(function () {
   if ($(this).find('a[href]').length) {
      $(this).css('cursor', 'pointer');
   }
});

这是demo