如何在页面加载MVC asp.net上运行JQuery函数
我有一个JQuery函数如何在页面加载MVC asp.net上运行JQuery函数,jquery,asp.net-mvc,Jquery,Asp.net Mvc,我有一个JQuery函数FetchFunctions(),在加载页面时需要运行该函数。我不知道如何在MVC中使用模板来实现这一点。我在这一页上没有一节。将其添加到_布局页面没有意义。在页面内部只需添加一个脚本标记 somepage.cshtml <script> window.onload = function(){ //script goes here }; //or if you prefer jQuery $(function(){ //script goes
FetchFunctions()
,在加载页面时需要运行该函数。我不知道如何在MVC中使用模板来实现这一点。我在这一页上没有一节。将其添加到_布局页面没有意义。在页面内部只需添加一个脚本标记
somepage.cshtml
<script>
window.onload = function(){
//script goes here
};
//or if you prefer jQuery
$(function(){
//script goes here
});
</script>
window.onload=函数(){
//脚本在这里
};
//或者如果您更喜欢jQuery
$(函数(){
//脚本在这里
});
只需在HTML中包含以下内容:
<script>
$(function () { FetchFunctions() });
</script>
$(函数(){FetchFunctions()});