开发者

Call Javascript/Jquery from Razor?

As I'm still getting into Razor an开发者_StackOverflow中文版d JQuery, I'm wondering if it's possible to call your Javascript or JQuery functions from your inline razor script?

I ran into this question while trying to implement load spinners that were dependent on razor-level validation.


As I'm still getting into Razor and JQuery, I'm wondering if it's possible to call your Javascript or JQuery functions from your inline razor script?

Of course that it is possible. Razor is just a templating engine which translates to HTML. So you could do everything that you could do in HTML:

<script type="text/javascript">
    $(function() {
        alert($('div').html());
    });
</script>
<div>@DateTime.Now.ToString("dd/MM/yyyy")</div>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜