简体   繁体   English

jQuery中的鼠标悬停元素

[英]Mouse hover element in jquery

I have html code like this: 我有这样的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>

I would like to change cursor when mouse hover this element, show pointer if <span class="tree-title"> constainse a href and default , if no. 我想在鼠标悬停此元素时更改光标,如果<span class="tree-title"> a hrefdefault ,则显示pointer ,否则。

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

Here's a demo 这是一个演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM