如何从视图中的@IF bolck调用js函数。 [英] How to called js function from @IF bolck which is in view.

查看:78
本文介绍了如何从视图中的@IF bolck调用js函数。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



@if(条件)

{

需要从这里调用js函数

}


@if(condition)
{
Need to call js function from here
}







<script type="text/javascript">
    $(document).ready(function () {
        debugger;
        function setactive(id)
        {           
           .....
        }
    });
                    </script>





请告诉我如何从View调用js函数。



我尝试了什么:



我有谷歌它并尝试了不同的解决方案,但不能来到解决方案。



Please tell me how can we called the js function from View.

What I have tried:

I have google it and tried different solutions but could not come to the solution.

推荐答案

(document).ready(function(){
debugger;
function setactive(id)
{
.....
}
});
< / script>
(document).ready(function () { debugger; function setactive(id) { ..... } }); </script>





请告诉我如何从View调用js函数。



我尝试了什么:



我有谷歌它并尝试了不同的解决方案,但不能来解决方案。



Please tell me how can we called the js function from View.

What I have tried:

I have google it and tried different solutions but could not come to the solution.


如果你的意思是只是setactive函数



If you mean just the setactive function

<script type="text/javascript">
    function setactive(id) {
        alert(id);
    }
</script>

@if (condition)
{
    <script>
        setactive(1);
    </script>
}





如果你的意思是整件事





if you mean the whole thing

@if (condition)
{
<script type="text/javascript">


(document).ready(function (){
function setactive(id)
{

}
});
< / script>
}
(document).ready(function () { function setactive(id) { } }); </script> }


这篇关于如何从视图中的@IF bolck调用js函数。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆