$(function(){ var tags = $(".tag"); tags.each(function(){ var r = Math.floor(Math.random()*255); var g = Math.floor(Math.random()*255); var b = Math.floor(Math.random()*255); $(this).css("background-color","rgb(" + r +"," + g +"," + b + ")"); }) })
转载于:https://www.cnblogs.com/hfzps/p/4386604.html