我有一个按钮,例如
<asp:Button ID="btnfirstnext" TabIndex="1" runat="server" Text="Next" class="action-button" OnClick="btnfirstnext_Click" />
我有像 javascript
<script>
$(function () {
//jQuery time
var current_fs, next_fs, previous_fs; //fieldsets
var left, opacity, scale; //fieldset properties which we will animate
var animating; //flag to prevent quick multi-click glitches
$(".next1").click(function () {
if (animating) return true;
animating = true;
current_fs = $(this).parent();
next_fs = $(this).parent().next();
//activate next step on progressbar using the index of next_fs
$("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
//show the next fieldset
next_fs.show();
//hide the current fieldset with style
current_fs.animate({ opacity: 0 }, {
step: function (now, mx) {
//as the opacity of current_fs reduces to 0 - stored in "now"
//1. scale current_fs down to 80%
scale = 1 - (1 - now) * 0.2;
//2. bring next_fs from the right(50%)
left = (now * 50) + "%";
//3. increase opacity of next_fs to 1 as it moves in
opacity = 1 - now;
current_fs.css({ 'transform': 'scale(' + scale + ')' });
next_fs.css({ 'left': left, 'opacity': opacity });
},
duration: 800,
complete: function () {
current_fs.hide();
animating = false;
},
//this comes from the custom easing plugin
easing: 'easeInOutBack'
// $('btnfirstnext').trigger('click');
});
});
我想在单击按钮时调用此 javascript
请帮我
我尝试过 OnClientClick="javascript: return .next1;"
但它不起作用,我还尝试使用 onclicentclick
这是可行的,但由于其他一些问题我不想使用它。class=".next1 action-button"
="return false;"
最佳答案
更改按钮 ID 与点击事件 ID 名称 next1
的匹配,并从按钮中删除 OnClick="btnfirstnext_Click"
<asp:Button ID="next1" TabIndex="1" runat="server" Text="Next" class="action-button" />
并更改您的函数参数,如下所示,这将调用此函数
$("#next1").click(function () {
关于javascript - 使用按钮 OnClick 事件调用 Javascript 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37088763/