Bootstrap onClick按钮事件 [英] Bootstrap onClick button event
问题描述
这似乎是一个愚蠢的问题,但只是得到了引导程序并且它没有在网站上提供关于向按钮添加Javascript回调的任何示例...
This seems a silly question but just got bootstrap and It doesnt gives any examples on the website about adding a Javascript callback to a button...
尝试设置我的按钮id标志,然后
Tried setting my button an id flag and then
<div class="btn-group">
<button id="rectButton" class="btn">Rectangle</button>
<button class="btn">Circle</button>
<button class="btn">Triangle</button>
<button class="btn">Line</button>
<button class="btn">Curve</button>
<button class="btn">Pic</button>
<button class="btn">Text</button>
<button class="btn">Gradient</button>
</div>
我想为矩形按钮添加一个回调...
I want to add a callback to Rectangle button...
$('#rectButton').on('show', function (e) {
//ACTION
})
无法获得引导回调的点。
cant get the point of bootstrap callbacks.
全部我可以在网上找到面向Rails + Bootstrap ......没有bootstrap和JS。
All I could found on the web is oriented to Rails + Bootstrap... no bootstrap and JS only.
推荐答案
没有在js中显示
事件 - 您需要将按钮绑定到点击
事件:
There is no show
event in js - you need to bind your button either to the click
event:
$('#id').on('click', function (e) {
//your awesome code here
})
请注意,如果你的按钮在<$ c $里面c> form ,您可能更喜欢将整个表单绑定到 submit
事件。
Mind that if your button is inside a form
, you may prefer to bind the whole form to the submit
event.
这篇关于Bootstrap onClick按钮事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!