简体   繁体   English

jQuery语法错误非法字符

[英]jquery Syntax error illegal character

I keep receiving error of illegal character in firebugs 我不断收到萤火虫中非法字符的错误

 $('#service_chk').click(function () {
     var $this = $(this);
     if ($this.is(':checked')) {
         $('#service').css('display'​​​​​​​​​​​​​​​​​​​​​​​​​​​,'block');​​​​​​
     } else {
         $('#service').css('display'​​​​​​​​​​​​​​​​​​​​​​​​​​​,'none');​​​​​​
     }
 });

Error keep pointing "coma" in $('#service').css('display'​​​​​​​​​​​​​​​​​​​​​​​​​​​,'block');​​​​​​ 错误在$('#service')。css('display' “);

and this is my view 这是我的看法

<tr>
    <td><input type="checkbox" id="service_chk"></td>
    <td style="text-align:center;"><input type="text" class="form-control" id="service" style="display:none;"></td>
</tr>

Im on the way learning javascript, please help me, thanks. 我正在学习javascript,请帮助我,谢谢。

Issue is because of encoding in your text editor or the IDE which you are using. 问题是由于您使用的文本编辑器或IDE中的编码引起的。 Copy paste your script into jsfiddle and you'll see the errors. 复制将脚本粘贴到jsfiddle中,您将看到错误。 在此处输入图片说明

HTML HTML

        <tr>
        <td>
            <input type="checkbox" id="service_chk">
        </td>
        <td style="text-align:center;">
            <input type="text" class="form-control" id="service" style="display:none;">
        </td>
    </tr>

Link: http://jsfiddle.net/GCu2D/1655/ 链接: http//jsfiddle.net/GCu2D/1655/

you have a bunch of invisible spaces (zero width spaces) in your code. 您的代码中有一堆不可见的空格(零宽度空格)。

below is the fixed version of your code: 以下是您的代码的固定版本:

  $('#service_chk').click(function () { var $this = $(this); if ($this.is(':checked')) { $('#service').css('display','block'); } else { $('#service').css('display','none'); } }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <tr> <td><input type="checkbox" id="service_chk"></td> <td style="text-align:center;"><input type="text" class="form-control" id="service" style="display:none;"></td> </tr> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM