单击后如何更改按钮的CSS [英] How to change CSS of button after click

查看:92
本文介绍了单击后如何更改按钮的CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是webform1代码,我点击按钮点击javascript函数



<%@ Page Language =C#AutoEventWireup =trueCodeBehind = WebForm1.aspx.csInherits =valid_try2.WebForm1%>



<!DOCTYPE html>



< html xmlns =http://www.w3.org/1999/xhtml>

< head runat =server>

< script type =text / javascriptsrc =JavaScript1.js>< / script>



< title>< / title> ;

< / head>

< body>

< form id =form1runat =server>

This is webform1 code where i call a javascript function on button click

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="valid_try2.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script type="text/javascript" src="JavaScript1.js"></script>

<title></title>
</head>
<body>
<form id="form1" runat="server">





< button id =btnclass =xxname =btnonclick =abc() >按钮< /按钮>



<button id="btn" class="xx" name="btn" onclick="abc()">Button</button>



< / form>

< / body>

< / html>





这是css的样式表文件

.xx {

边框:5px实心绿色;

}



.yy {

border:5px solid red;

}



这是javascript文件



function abc(){

$(#btn)。removeClass(xx);

$(#btn)。addClass(yy);

}



我尝试了什么:



i want按钮点击后改变班级,但我不这样做,请帮助我帮助我


</form>
</body>
</html>


This is stylesheet file for css
.xx {
border: 5px solid green;
}

.yy {
border: 5px solid red;
}

This is javascript file

function abc() {
$("#btn").removeClass("xx");
$("#btn").addClass("yy");
}

What I have tried:

i want to change the class after button click but i am not do this plz help me kindly

推荐答案

(#btn)。removeClass(xx);
("#btn").removeClass("xx");


(#btn)。addClass(yy);

}



我尝试了什么:



i想要在点击按钮后更改课程,但我不这样做,请帮助我帮助我
("#btn").addClass("yy");
}

What I have tried:

i want to change the class after button click but i am not do this plz help me kindly


你好



最好的方法是使用Javascript / jQuery:



Hello

The best way is ti using Javascript / jQuery:


这篇关于单击后如何更改按钮的CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆