I have the following code:
This is a <span id="sentence">sentence</span>.
When a user hovers over sentence
, I would like an underline to fade in under the word.
This seems like such a simple problem, but I have not been able to figure out how best to do it. Just to be clear, I cannot just use css:hover
. I need to do this with JQuery given the actual problem is more complicated and requires more control than that illustrated here. Thanks very much for your help in advance.
This might not fit your needs, and I realize you specifically don't want to use CSS. But just in case...
This is a <span id="sentence">sentence.</span>
span {
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
transition: all 0.5s;
border-bottom: 1px solid transparent;
}
span.clicked {
border-bottom: 1px solid black;
}
$('span').click(function(){
$(this).addClass('clicked');
});
http://jsfiddle.net/as42u/4/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With