how to move text on mouse over in jquery?

前端 未结 1 1176
庸人自扰
庸人自扰 2021-01-28 16:00

How to make a link moving to left when mouse over? I want the text move back when mouse out. Is it possible with jquery? Please help.

Thank You

相关标签:
1条回答
  • 2021-01-28 16:39

    You would use CSS regardless if it's in jQuery or not, not sure why you would use jQuery to begin with, but anyways, here is an example:

     <a href="#">Move me Left</a>
    
     <script type="text/javascript" language="javascript">
        $("a").hover(function(){ $(this).css('margin-left','-50px') });
     </script>
    

    The margin-left is set to -50px here (minus to go backwords), but can be changed according to your liking.

    Otherwise in CSS all you would need to do is:

     a:hover { margin-left: -50px; }
    

    See how much easier that is in CSS?

    0 讨论(0)
提交回复
热议问题