0

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.

1
  • is the container <span class="tree-title"> dynamic? I mean that sometime it contains <a> inside and sometimes not? Commented Aug 21, 2012 at 10:02

1 Answer 1

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

Here's a demo

Sign up to request clarification or add additional context in comments.

4 Comments

It took me ten seconds to figure out why you weren't using :hover. My bad. @revolutionkpi: you can't get any better than this answer. +1
I know that I shoude use this property, tahnks, but I is a bit difficult to select this element
It doesn't select element for which I will use this property. I try: $("span.tree-title").on('hover', function() { alert($(this).html());
I add this content dynamicaly. so the question is how to select and then change this property

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.