1

I need some text to move to the right when the mouse hovers over it, here's what I have so far JS:

$("#mainnav li").hover(function() {
$(this).css('padding-left', '50px');});

HTML:

<ul id="mainnav"> 
<li>hello</li>
<li>hello 1</li>
<li>hello 2</li>
</ul>

1 Answer 1

5

If you want to use JQuery you can do it like this, or you can do this with just CSS Fiddle

$('#mainnav li').hover(function() {
  $(this).css('padding-left', '30px');
}, function() {
  $(this).css('padding-left', '0');
});
li {
  transition: all 0.3s ease-in;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul id="mainnav"> 
  <li>hello</li>
  <li>hello 1</li>
  <li>hello 2</li>
</ul>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.