How to change display from another class?

I have a problem that I cannot understand.

I have two classes:

<div class="left" style="display:block;"></div> <div class="leftlarge" style="display:none"> <h1>Welcome</h1> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </div> 

This is what I want:

  • .leftlarge onMouseEnter change style="display:none " to style="display:block"
  • .left onMouseEnter change style="display:block" to style="display:none"

I tried with css :hover , but that didn't work. Thus, I cannot display text in this class. I also applied some javascripts that I found on the Internet, but no one worked the way I wanted.

I appreciate any help.

+4
source share
2 answers

Do you mean something similar, but probably without the flicker effect? http://jsfiddle.net/Ce8PW/2/

 $(function(){ $('.left').mouseenter(function(){$('.leftlarge').show();$(this).hide();}); $('.leftlarge').mouseenter(function(){$('.left').show();$(this).hide();}); }); 

But there must be something in div.left, at least a &nbsp; , or the div will not be displayed at all, and you cannot attach anything to it.

If you immediately after the show / hide onmouseover effect, try this instead: http://jsfiddle.net/2ztUp/

If you want to continue displaying text when the mouse is over it, let the .lft div wrap the div text as follows: http://jsfiddle.net/hKRPY/

+1
source

This is what you are looking for .... !!

Give the div identifier, ('#none_blk') will return true if the object is displayed on the screen, otherwise it will return false

 function isDisplayed(object) { if($(object).css('display') == 'block') { return true; } return false; } 

EDIT:

Otherwise, you can use toggleClass ()

0
source

All Articles