2020javaweb教程之jQuery的css样式

2020javaweb教程之jQuery的css样式

css样式

<style>
    .a{color:red;font-size: 40px;}
    .b{font-style: italic;color: aqua;font-size: 40px;}
</style>

jQuery

<p>这是一段文本</p>
<script>
    $(function(){
        $("p").mouseover(function(){
            $(this).removeClass();//移除所有的样式
            $(this).addClass("a");//添加样式 a
        }).mouseout(function(){
            $(this).removeClass();//移除所有的样式
            $(this).addClass("b");//添加样式 b
        })
    })
</script>



Comments

Leave a Reply

Your email address will not be published. Required fields are marked *