我有这样的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
如果<span class="tree-title">
包含a href
和default
, 如果不。
最佳答案
$('.tree-title').each(function () {
if ($(this).find('a[href]').length) {
$(this).css('cursor', 'pointer');
}
});
这是一个demo
关于javascript - jquery中的鼠标悬停元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12052344/