你的位置:首页 > ASP.net教程

[ASP.net教程]mvc view 中 js 不反应


 1 <!doctype html> 2 <html> 3 <head> 4   <meta charset="utf-8"> 5   <title>Title</title> 6   <link href="http://www.cnblogs.com//Content/Songsen/css.css" rel="stylesheet" type="text/css"> 7   <script type="text/javascript" src="http://www.cnblogs.com//Script/Songsen/jquery-1.9.1.js"></script> 8   @RenderSection("script",false) 9 </head>10 <body>11 12 </body>13 </html>

View Code

当把@RenderSection("script",false) 写在母版页的<head>标签里时,在view里@section script{}里面的js应该写在

$(document).ready();里面。

 

 1 @section script 2 { 3   <script type="text/javascript" src="http://www.cnblogs.com//Script/Songsen/jquery-1.9.1.js"></script> 4   <script type="text/javascript" src="http://www.cnblogs.com//Script/Manager.js"></script> 5   <script type="text/javascript"> 6     $(document).ready(function () { 7       $("form").submit(function (e) { 8         alert("nihao"); 9       });10     });11   </script>12 }

View Code