jquery Click Change class and Toggle

Source: Internet
Author: User

<HTML><Head><MetaCharSet= "Utf-8"><title></title><Scripttype= "Text/javascript"src= "Http://www.w3school.com.cn/jquery/jquery-1.11.1.min.js"></Script><style>. BG1{Background-image:URL (images/21.jpg);background-repeat:no-repeat;Color:#0CF;}. Bg2{Background-image:URL (images/22.jpg);background-repeat:no-repeat;Color:#F00;}</style><Scripttype= "Text/javascript">//parameter para1: ID value of the element you want to hidefunctionToggle1 (para1) {if ($("#p2"). attr ("class")=="bg1")    {        $("#p2"). attr ("class","Bg2"); }    Else     {        $("#p2"). attr ("class","bg1"); }    $("#"+para1). Toggle ();}</Script></Head><Body><PID= "P1">Here you will see or hide</P><PID= "P2"class= "BG1"OnClick= "Toggle1 (' P1 ')"style= "height:31px">Click here to show or hide the above section and change your style (including background, fonts, etc.)</P></Body></HTML>

jquery Click Change class and Toggle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.