用JQ试试。代码如下$("p").hover(function(){$("p").css("background-color","yellow");},function(){$("p").css("background-color","pink");});