Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mouse Over only on text not on entire row

How can I provide Mouse hover effect only on text not on entire row. I tried with Position(), But cam out with empty .Below is fiddle link,

<ul id='ulid'>
<li>Task1</li>
<li>Task2</li>
<li>Task3</li>
<li>Task4</li>
<li>Task5</li>
<li>Task6</li>
<li>Task7</li>
</ul>

<br /><br />


<br /><br />

<div id="show_details"></div>

jQuery(document).ready(function() {


$('ul#ulid li').hover(function() {
    $('#show_details').html($(this).text());
}, function() {
    $('#show_details').html('');
});
});

Please help

like image 236
EnterJQ Avatar asked Dec 07 '25 08:12

EnterJQ


1 Answers

Your li elements can't be block-display. There are a lot of ways to handle it, but one easy way is just to wrap them with spans and trigger the .hover on those spans:

<li><span>Task1</span></li>
...
$('ul#ulid li span').hover(function() {

http://jsfiddle.net/xneG5/

Programatically: http://jsfiddle.net/xneG5/2/

CSS only: http://jsfiddle.net/xneG5/3/

like image 88
Explosion Pills Avatar answered Dec 08 '25 21:12

Explosion Pills



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!