按下按钮后,在按钮周围添加粗矩形边框. [英] Add thick rectangle border around the button after it is pressed.

查看:133
本文介绍了按下按钮后,在按钮周围添加粗矩形边框.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对话框中有许多按钮.按下按钮后在其周围添加粗矩形边框,再次按下按钮后隐藏粗矩形边框.在按下许多按钮之后,所按下的按钮为粗矩形边框,直到再次按下它们为止.

该怎么做?

谢谢.

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


这篇关于按下按钮后,在按钮周围添加粗矩形边框.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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