Find & replace jquery

后端 未结 3 1890
感动是毒
感动是毒 2020-12-17 02:01

I have this code to give me a rollover on submit buttons, and I\'m trying to make it more generic:

$(\'.rollover\').hover(
            function(){ // Change          


        
3条回答
  •  孤城傲影
    2020-12-17 02:32

    $('.rollover').hover(
                function(){ // Change the input image's source when we "roll on"
                    var t = $(this);
                    t.attr('src',t.attr('src').replace(/([^.]*)\.(.*)/, "$1-over.$2"));
                },
                function(){ 
                    var t= $(this);
                    t.attr('src',t.attr('src').replace('-over',''));
                }
         );
    

提交回复
热议问题