Results 1 to 5 of 5

Thread: Show/Hide Div inside Div

  1. #1
    Join Date
    Nov 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Show/Hide Div inside Div

    Hi,

    When I pass the mouse over de image, it correctly show the icon/option (inside the this image), but when I try to click on this icon it show-off.
    The code below is runnable for tests.

    Thank for help


    Code:
    <html>
    <head><script src="http://jqueryui.com/jquery-1.6.2.js" type="text/javascript"></script></head>
    <body>
    <div style="position: relative">
    
    	<img src="http://irmaedviges.2toq.com/wp/wp-content/uploads/2010/09/Paisagens_446561914_paisagens_01-150x150.jpg" onmouseover="doOnmouseover()" onmouseout="doOnmouseout()">
    	
    	<div id="opcoes" style="position: absolute; top: 50px; left: 5px; display: none;">
    		<a href="www.google.com.br" target="_blank">
    			<img src="http://imagem.buscape.com.br/parceiros/rac/seta_esquerda.gif" >
    		</a>
    	</div>
    	
    </div>
    
    <span id="xxx"></span>
    <BR><span id="yyy"></span>
    
    <script type="text/javascript">
    	
    	countIn = 1;
    	countOut = 1;
    	function doOnmouseover() {
    		$('#opcoes').fadeIn(1000);
    		$('#xxx').text('doOnmouseover: ' + countIn++);
    	}
    	
    	function doOnmouseout() {
    		$('#opcoes').fadeOut(1000);
    		$('#yyy').text('doOnmouseout: ' + countOut++);
    	}
    </script>
    
    </body>
    </html>

  2. #2
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default

    what do you want to happen when you click?

  3. #3
    Join Date
    Nov 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    the problem is that icon disaper (fadeOut/hide) when I put the mouse over it... I wanna this icon only fadeOut where the mouse go out the main image

  4. #4
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default

    since you have jQuery already
    Code:
    <html>
    <head>
    <style>
    #pic {width:150px;}
    #opcoes {position: absolute; top: 50px; left: 5px; display:none; }
    </style>
    	
    <script src="http://code.jquery.com/jquery.min.js"></script>
    </head>
    <body>
    	
    <div id="pic">
    	<img src="http://irmaedviges.2toq.com/wp/wp-content/uploads/2010/09/Paisagens_446561914_paisagens_01-150x150.jpg">
    	<span id="opcoes">
    		<a href="www.google.com.br" target="_blank">
    			<img src="http://imagem.buscape.com.br/parceiros/rac/seta_esquerda.gif" >
    		</a>
    	</span>
    </div>
    
    <span id="xxx"></span>
    <BR><span id="yyy"></span>
    
    <script type="text/javascript">
    $(function() {	
    	$('#pic').mouseenter(function(){
    		$(this).find('span#opcoes').fadeIn(200);
    	});
    	
    	$('#pic').mouseleave(function() {
    		$(this).find('span#opcoes').fadeOut(200);
    	});
    });
    </script>
    
    </body>
    </html>

  5. #5
    Join Date
    Nov 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Excelent!!! It works thanks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •