javascript - 单击时隐藏按钮

标签 javascript html css

尝试使用 Bootstrap/JavaScript 在单击时隐藏按钮。这是我的按钮代码:

<a href="#menu-toggle" class="btn btn-primary btn-lg" id="menu-toggle" onclick="hideBtn();">I understand</a>

这是我的脚本:

<script type="text/javascript">
    function hidebtn(){
        document.getElementById('menu-toggle').style.display = 'none';
    }
</script>

它不起作用,有什么想法吗?谢谢!

最佳答案

用 jQuery 试试:

function hide(){
    $( "#button" ).addClass( "hide" );
}

HTML 和 CSS:

<a id="#button" onClick="hide()">Button</a>

#button.hide {
display: none;
}

关于javascript - 单击时隐藏按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32373038/

相关文章:

javascript - 在模式中显示 AJAX 确认

javascript - 在 javascript 中,如果 : x = []; x. push(x); 会发生什么?

html - 如何使图像从 CSS 响应

html - 对齐列时在表单 Bootstrap 上添加两个标签

php - 我如何使用 &lt;style&gt; 标签将 css 代码添加到 php 文件,当前方法不起作用。

jquery - 如果 URL 包含 X,则尝试向元素添加类

javascript - 更新 Raphael 饼图中的饼图切片大小

javascript - 在 Angular js 中注销时清除 $scope

html - 格式化双列表

javascript - ScrollTo 效果(href 到 div)