revolutionkpi
revolutionkpi

Reputation: 2682

Mouse hover element in jquery

I have html code like this:

<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.

Upvotes: 0

Views: 112

Answers (1)

Adi
Adi

Reputation: 5169

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

Here's a demo

Upvotes: 3

Related Questions