按下按钮后,在按钮周围添加粗矩形边框.
问题描述:
对话框中有许多按钮.按下按钮后在其周围添加粗矩形边框,再次按下按钮后隐藏粗矩形边框.在按下许多按钮之后,所按下的按钮为粗矩形边框,直到再次按下它们为止.
该怎么做?
谢谢.
There are many buttons in a dialog. Add thick rectangle border around the button after it is pressed and hide thick rectangle border after the button is pressed again. After I pressed many buttons ,the buttons that is pressed are of thick rectangle border until I pressed them again.
How to do this ?
Thank you.
答
如果您对基于Web的解决方案有疑问,那么使用jQuery将通过切换按钮的CSS类使此操作变得相当容易.
If you are asking this in regards to web-based solution, then using jQuery would make this fairly easy by switching the button''s CSS classes.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Buttons</title>
<style type="text/css">
.buttons
{
padding: 5px;
margin: 10px;
}
.thick
{
border: 4px solid blue;
}
.thin
{
border: 1px solid black;
}
</style>
</head>
<body>
<input id="" type="button" value="Button 1" />
<input id="" type="button" value="Button 2" />
<input id="" type="button" value="Button 3" />
<input id="" type="button" value="Button 4" />
<script src="scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
//Add base classes to all buttons on page
jQuery(function(
){
(:button").addClass("buttons thin") }); //点击时切换粗/细类
(":button").addClass("buttons thin") }); //Toggle thick/thin classes when clicked