javascript - 如何给jquery按钮添加边框

标签 javascript jquery html css

我正在尝试为 jquery 按钮添加边框。我的代码是:

JSP页面既有css又有javascript,

<style type="text/css">
    .borderClass{
        border-color: #C1E0FF;
        border-width:1px;
        border-style: solid;
}
</style>
<script language="JavaScript" type="text/javascript">
    function xxx() {
        jQuery("#completedInformation").dialog({
            buttons: {
                Cancel: function() {
                     jquery( this ).addClass('borderClass');
                 jQuery("#completedInformation").dialog( "close" );
            }
            }  
        });
    }
</script>

请给我建议。

最佳答案

使用 general sibling combinator因此无需为按钮定义额外的类。

CSS:

#completedInformation ~ .ui-dialog-buttonpane button {
    border: #f00 1px solid;
}

fiddle :http://jsfiddle.net/gnSuw/

关于javascript - 如何给jquery按钮添加边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18722850/

相关文章:

jquery - 我可以使用 Jquery 将自定义属性插入到 HTML 元素中吗?

javascript - 聊天/聊天盒系统的最佳技术是什么?普通JS,JQuery,Websocket或其他?

jquery - 鼠标移开不适用于所有方向

javascript - 选中复选框并单击重定向到 PHP 中的另一个页面

javascript - 在 AngularJS 中将数组从父组件传递到子组件

javascript - 卡片按 Y 轴旋转

jQuery 获取 data-value 的某个值

javascript - 通过 id name 检查元素是否有子节点

javascript - 将鼠标悬停在圆圈上时在圆圈下方显示文本

html - 带有 CSS 的 div 上不需要的边距