jQuery plugin for generating multi coloured text which changes colour on hover

前端 未结 2 1988
予麋鹿
予麋鹿 2021-01-28 11:42

I would like to generate multicoloured text for various links, with a random assignment of colours to individual letters, from a pre-specified array of colours, which would chan

2条回答
  •  被撕碎了的回忆
    2021-01-28 12:08

    You could try this:

       $('a').on('hover', function( {
          $(this).css('color', getRandomColor());
         })
       );
    
    function getRandomColor() {
      var myAwesomeColorList['#ccc', '#fff'];
    
      return myAwesomeColorList[Math.floor((Math.random()*myAwesomeColorList.length))]
    }
    

提交回复
热议问题