jQuery replace text of element on hover

前端 未结 5 762
刺人心
刺人心 2020-12-03 06:04

With jQuery, I\'m trying to replace the text, including the span, inside these links on hover. Then when the user hover\'s off, the original text is displayed again.

5条回答
  •  忘掉有多难
    2020-12-03 06:46

    add another function to the hover event like this:

    $('.btn').hover(function(){
        $(this).text("I'm replaced!");
    }, function() {
        $(this).text("Replace me please");
    });
    

    Link for demo

提交回复
热议问题