In this article, JQuery is used to operate the class attribute to achieve the button switch effect on the page.
First define two classes:
.controlOff{
display:inline-block;
width:130px;
height:36px;
cursor:pointer;
background-image:url("../iclass/images/ teach_off.png");
background-repeat: no-repeat;
}
.controlOn{
display:inline-block;
width:130px;
height :36px;
cursor:pointer;
background-image:url("../iclass/images/teach_on.png");
background-repeat: no-repeat;
}
Define another hyperlink tag:
Then write the JS script to complete the switching effect:
function switchTeachControl(){
var target = $( "#teachControl");
if(target.hasClass("controlOff")){
target.removeClass("controlOff");
target.addClass("controlOn");
}else{
target.removeClass("controlOn");
target.addClass("controlOff");
}
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn