Jquery 在twitter引导中显示/隐藏带有数据属性的alertbox

Jquery 在twitter引导中显示/隐藏带有数据属性的alertbox,jquery,html,twitter-bootstrap,custom-data-attribute,Jquery,Html,Twitter Bootstrap,Custom Data Attribute,我想使用数据属性在推特引导中显示隐藏警报框,这是因为我可以在一个页面中使用多个警报框 现在我有这个, <a href="#" data-box="myAlert">Hint</a> //data-box is the id of the box <div id="myAlert" class="alert alert-info"> <a class="close" data-dismiss="alert" href="#">&ti

我想使用数据属性在推特引导中显示隐藏警报框,这是因为我可以在一个页面中使用多个警报框

现在我有这个,

<a href="#" data-box="myAlert">Hint</a> //data-box is the id of the box

<div id="myAlert" class="alert alert-info">
    <a class="close" data-dismiss="alert" href="#">&times;</a>
    <p>Alert Me !!!!</p>
</div>
//数据框是框的id
提醒我

试试看

演示:

更新
使用“定位”选项卡显示/隐藏

<a href="#" data-box="myAlert">Hint</div>

<div id="myAlert" class="alert alert-info hide">
    <p>Alert Me !!!!</p>
</div>  

$(function(){

  $('[data-box]').click(function(){
    var $this = $(this);
    $('#' + $this.data('box')).toggle()
    return false;
  });

});

你能解释一下它是如何不适合你的吗?我没有jquery…这是因为你正在使用bootstrap提供的
关闭
按钮,它会删除屏幕上的警报框click@SaurabhLP如果要在上面代码中单击链接change.show()时再次隐藏它,请将.toggle()@SaurabhLP编写您自己的close方法,它只是隐藏警报,而不是删除警报it@ArunPJohny如果我移除关闭按钮并为显示/隐藏制作“提示”锚…@SaurabhLP,那会更好
<a href="#" data-box="myAlert">Hint</div>

<div id="myAlert" class="alert alert-info hide">
    <p>Alert Me !!!!</p>
</div>  

$(function(){

  $('[data-box]').click(function(){
    var $this = $(this);
    $('#' + $this.data('box')).toggle()
    return false;
  });

});