开发者

Using a jQuery selector that uses the '@' symbol in an MVC3 application

开发者 https://www.devze.com 2023-04-12 01:06 出处:网络
开发者_运维知识库Here\'s what I\'m trying to run: <script type=\"text/javascript\"> $(\"input[@name=\'paymenttype\']\").change(function(){
开发者_运维知识库

Here's what I'm trying to run:

<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>

However, the Razor view engine is catching my @ symbol.

Is there some way to tell it to ignore that specific instance of the @ symbol?


You shouldn't be using @ in those selectors.
This syntax has been deprecated since jQuery 1.2, and it was removed in 1.3.

To answer your questions, you can output a literal @ by writing @@, or you can move that code to an external (non-Razor) .js file.

0

精彩评论

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

关注公众号