Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用按钮OnClick事件调用Javascript函数_Javascript_C#_Jquery_Asp.net - Fatal编程技术网

使用按钮OnClick事件调用Javascript函数

使用按钮OnClick事件调用Javascript函数,javascript,c#,jquery,asp.net,Javascript,C#,Jquery,Asp.net,我有一个像这样的按钮 <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,

我有一个像这样的按钮

<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');

            });
        });

$(函数(){
//jQuery时间
var current\u fs,next\u fs,previous\u fs;//字段集
var left,opacity,scale;//我们将设置动画的字段集属性
var animating;//防止快速多点单击故障的标志
$(“.next1”)。单击(函数(){
如果(动画)返回true;
动画=真;
当前_fs=$(this.parent();
next_fs=$(this.parent().next();
//使用next_fs的索引在progressbar上激活下一步
$(“#progressbar li”).eq($(“字段集”).index(next_fs)).addClass(“活动”);
//显示下一个字段集
next_fs.show();
//使用样式隐藏当前字段集
当前动画({opacity:0}{
步骤:函数(现在是mx){
//随着当前_fs的不透明度降低到0-存储在“now”中
//1.将电流放大至80%
比例=1-(1-现在)*0.2;
//2.从右侧带下一个_fs(50%)
左=(现在是*50)+“%”;
//3.当下一个_fs移入时,将其不透明度增加到1
不透明度=1-现在;
当前的{'transform':'scale('+scale+')};
css({'left':left'opacity':opacity});
},
持续时间:800,
完成:函数(){
当前_fs.hide();
动画=假;
},
//这来自自定义的放松插件
放松:“轻松返回”
//$('btnfirstnext')。触发器('click');
});
});

我想在单击按钮时调用此javascript 请帮帮我
我尝试过类似于
OnClientClick=“javascript:return.next1;”“
但它不起作用,我还尝试了
class=“.next1操作按钮”
OnClientClick=“return false;”
这是可行的,但由于其他一些问题,我不想使用它。

更改按钮id与单击事件id名称的匹配
next1
并从按钮中删除
OnClick=“btnfirstnext\u click”

<asp:Button ID="next1" TabIndex="1" runat="server" Text="Next" class="action-button" />

您可以尝试以下解决方案之一:

1) 有功能

<asp:Button TabIndex="1" runat="server" Text="Next" class="action-button" OnClick="javascript:doSomething()" />

<script type="text/javascript">
function doSomething() {
   //do something
}
</script>

函数doSomething(){
//做点什么
}
2) 带类(按钮定义中类名前不带点)


$(“.next”)。单击(函数(){
//做点什么
});
3) 带身份证


$(“#下一步”)。单击(函数(){
//做点什么
});

Juat add class next1 in button并删除onclick事件,js将自动运行该事件,因为您已经为js中的next1绑定了新增的点击功能,不起任何作用,因为我也想使用onclick事件
<asp:Button TabIndex="1" runat="server" Text="Next" class="action-button" OnClick="javascript:doSomething()" />

<script type="text/javascript">
function doSomething() {
   //do something
}
</script>
<asp:Button TabIndex="1" runat="server" Text="Next" class="action-button next" />

<script type="text/javascript">
$(".next").click(function() {
   //do something
});
</script>
<asp:Button ID="next" TabIndex="1" runat="server" Text="Next" class="action-button" />

<script type="text/javascript">
$("#next").click(function() {
   //do something
});
</script>