mouseenter hover

0

I want to make that when moving the mouse over the page the space of the cell li of the first column is put in the same cell of the next two columns. The code that I am trickling is the following.

I tried hover, mouseneter and mouseleave.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!DOCTYPE html>
    <html>
    <head>
    <title>Title of the document</title>
    <script src="jquery-3.3.1.js"></script>
    
    <script type="text/javascript">
    	
    	$(document).ready(function() {
    		
    		$( "li" ).hover(
    			
      			function() {
      				var id = $(this).index();
    				var myHeight = $(this).height();
      				$( "ul.o-list" ).each(function() {
      					$(this).find( 'li' ).eq(id).height(myHeight);
      				});
       			});
    			
    			$( "li" ).mouseenter(
      			function(){
      				var id = $(this).index();
    				var myHeight = $(this).height();
    				/*$("ul.pp").mouseenter(function(){
    					
    				$(".pp span").text (x += 1 );
    				});*/
      				$( "ul.o-list" ).each(function() {
      					$(this).find( 'li' ).eq(id).height(myHeight)//.css({'background-color': 'blue', 'color': 'red'});	
      				});
       			});
    			
    		$( "li" ).mouseleave(
    			
    		    function() {
      				var id = $(this).index();
    				var myHeight = $(this).height();
      				$( "ul.o-list" ).each(function() {
      					$(this).find( 'li' ).eq(id).height(30)//la idea es que se quede el height del li original
      				});
       			});			
    	});
    
    </script>
    </head>
    
    <body>
    The content of the document......
    </body>
    <div>
    <ul class="o-list">
      <li ><span>Coffee <br><br>SDSS</span></li>
      <li id="">Tea</li>
      <li>Milk<br><br>sdsd</li>
    </ul>
    <ul class="o-list">
      <li>Coffee</li>
      <li>Tea</li>
      <li>Milk</li>
    </ul>
    <ul class="pp">
    	<li> lol<span> </span></li>
    </ul>
    
    <ul class="o-list">
      <li><span>Coffee</span></li>
      <li>Tea</li>
      <li>Milk</li>
    </ul>
    
    </div>
    </html>
    
asked by Dani Serra 28.06.2018 в 08:32
source

2 answers

0

The doubt has not been very clear to me, but I will try to offer you an answer. The problem that I see in the code is that you select the list incorrectly and that's why it makes you the event in all the lists.

I have used the hover event and I have done that by going over the first list take the width and move to the lists below. If you need something else, ask without fear.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!DOCTYPE html>
    <html>
    <head>
    <title>Title of the document</title>
    <script src="jquery-3.3.1.js"></script>
    
    <script type="text/javascript">
    	
    	$(document).ready(function() {
    		
    		$( "ul:eq(0) li" ).hover(
    			
      			function() {
      				var id = $(this).index();
    				var myHeight = $(this).height();
      				$( "ul.o-list" ).each(function() {
      					$(this).find( 'li' ).eq(id).css('height' ,myHeight);
      				});
       			});
    			
    			
    	});
    
    </script>
    </head>
    
    <body>
    The content of the document......
    </body>
    <div>
    <ul class="o-list">
      <li ><span>Coffee <br><br>SDSS</span></li>
      <li id="">Tea</li>
      <li>Milk<br><br>sdsd</li>
    </ul>
    <ul class="o-list">
      <li>Coffee</li>
      <li>Tea</li>
      <li>Milk</li>
    </ul>
    <ul class="pp">
    	<li> lol<span> </span></li>
    </ul>
    
    <ul class="o-list">
      <li><span>Coffee</span></li>
      <li>Tea</li>
      <li>Milk</li>
    </ul>
    
    </div>
    </html>
    
answered by 28.06.2018 в 10:24
0

Yes, the theme is to use the hover, which is equivalent to mouseenter and mouseleave. What I want is for the cells in the following columns to take the same size as the largest (that is, Coffee
ss) when the mouse hovers over. That is to say the 3 of coffee, and that when leaving the div's mouse it returns to the original size and when it happens again it adapts to the size of the largest one. with the prevheight it does not work for me.

<!DOCTYPE html>

Title of the document

    $ (document) .ready (function () {         var prevHeight = $ ('li'). height ();         console.log (prevHeight);         $ ("li") .hover (         // var myHeight = 0;             function () {                 var id = $ (this) .index ();                 var myHeight = $ (this) .height ();                 $ ("ul.o-list") .each (function () {                     $ (this) .find ('li') .eq (id) .height (myHeight);                 });             }, function () {                 $ ("ul.o-list") .each (function () {                     //$('li').height(prevHeight);                 });             });         });

The content of the document ......

  
  • Coffee
    ss
  •   
  • Tea
  •   
  • Milk
  •   
  • Coffee
  •   
  • Tea
  •   
  • Milk
  •   
  • Coffee
  •   
  • Tea
  •   
  • Milk
  •     
    answered by 28.06.2018 в 15:52