2015-10-07 45 views
0

我使用引导程序和有饼干,看起来像这样的警告:自举警报的onclick dissmiss

<div class="alert alert-info fade in"> 
    <button class="close" data-dismiss="alert" aria-label="close" title="close">&times;</button> 
    <strong>Info!</strong> This site uses cookies, by using this site you consent to the use of cookies. 
</div> 

但是我希望能够有一个onclick事件,做一样的关闭按钮,在许多谷歌(和灵魂搜索,如果它是值得的...),我什么也没有提出。

任何人都可以帮助我吗? (无论是做在JavaScript/jQuery的或HTML是理想的,在此先感谢:))

+0

onClick event on什么元素?做什么? –

+0

@XahedKamal,这将是onclick事件的div本身,并执行与按钮相同的工作,以关闭/关闭警报 –

回答

0

我不能相信这是这个简单的到底......我这个固定:

<div class="alert alert-info fade in" data-dismiss="alert" aria-label="close" title="close"> 
    ... 
</div> 

只要复制并粘贴数据辞退等进入div元素...

0

你可以实现这种方式 -

$('.alert').click(function(){ 
     $('.alert').alert('close') 
}); 

.alert被警告框的类名,或者你可以给个e alert box一个id并用编程方式关闭它