2

I am using the Jquery UI tabs, and want to change the properties of an element on mouseover.

My HTML is this:

<ul id="sub-tabs"> <li><a href="#000"><span>000<br /><p id="ct1">General</p></span></a></li> </ul>...

And jquery is:

$('#guide-nav ul#sub-tabs span').mouseover(function() {
   $("#guide-nav ul#sub-tabs li p").css("display", "none"); 
});

But this is not working.

4 Answers 4

1
<ul id="sub-tabs">
    <li><a href="#000"><span>000<br /><p id="ct1">General</p></span></a></li>
</ul>

Jquery is:

$('#guide-nav ul#sub-tabs span').mouseover(function() {
   $("#guide-nav ul#sub-tabs li a span p").css("display", "none"); 
});

Or try this:

$('#guide-nav ul#sub-tabs span').mouseover(function() {
   $("p#ct1").css("display", "none"); 
});

Or this:

$('#guide-nav ul#sub-tabs span').mouseover(function() {
   $(this).find('p').css("display", "none"); 
});
Sign up to request clarification or add additional context in comments.

1 Comment

This did not seem to work either. I was thinking that maybe the Jquery UI Tabs may be rewriting the styles and/or names of the elements, so I removed the call, and still no go.
0

Use this

$('#guide-nav ul#sub-tabs span').mouseover(function() {
   $("#guide-nav ul#sub-tabs li p").css({display:"none"}); 
});

2 Comments

That is just another way to write .css("display","none") and would not change anything about how his code reacts.
Still no go. I may try in a independentenvironment, to see if some other code on the page is messing with it...
0

Okay, i wrapped this in a function and it works...

$(function() {                                             
    $('#guide-nav ul#sub-tabs li a span').mouseover(function() {
        $(this).find('p').css("display", "none"); 
    });
});

I decided to use the above statement to only hide the elements within the selected tab, because there will be multiples

Comments

0

When I try your code it actually works. Are you sure that the DOM has finished loading when you are executing the javascript?

$(document).ready(function() {
  $('#guide-nav ul#sub-tabs span').mouseover(function() {
    ("#guide-nav ul#sub-tabs li p").css("display", "none");
  });
});

Instead of .css("display", "none"); you can also use .hide()

Comments

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.