【问题标题】:Using a jQuery selector that uses the '@' symbol in an MVC3 application在 MVC3 应用程序中使用使用“@”符号的 jQuery 选择器
【发布时间】:2011-10-11 14:30:01
【问题描述】:

这是我要运行的内容:

<script type="text/javascript">
    $("input[@name='paymenttype']").change(function(){
        if ($("input[@name='paymenttype']:checked").val() == 'deposit') {
            //Display deposit form.
        }
        else if ($("input[@name='paymenttype']:checked").val() == 'creditcard') {
            // Display credit card form.                
        }
    });
</script>

但是,Razor 视图引擎正在捕获我的 @ 符号。

有没有办法让它忽略@ 符号的特定实例?

【问题讨论】:

标签: jquery asp.net-mvc-3 selector


【解决方案1】:

您不应该在这些选择器中使用@
这种语法自 jQuery 1.2 起已被弃用,并在 1.3 中被删除。

要回答您的问题,您可以通过编写 @@ 来输出文字 @,或者您可以将该代码移动到外部(非 Razor).js 文件。

猜你喜欢
  • 2012-03-07
  • 1970-01-01
  • 2019-11-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-28
  • 1970-01-01
  • 2015-07-22
相关资源
最近更新 更多