Home  >  Q&A  >  body text

$( )里一会儿用单引号,一会儿用双引号 请求大神给我解释一下为啥来的?

如题

phpcn_u226phpcn_u2262867 days ago1336

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-09-30 23:50:20

    $( ) uses single quotes for a while, and double quotes for a while. Ask the master to explain to me why? - PHP Chinese website Q&A - $( ) uses single quotes for a while, and double quotes for a while. Ask the master to explain to me. Explain why you are here? - PHP Chinese website Q&A

    Take a look around and learn.

    reply
    0
  • 阿神

    阿神2017-01-04 16:14:26

    单引号和双引号其实没啥区别,看你自己习惯了

    <input type="button" onclick="alert("1")">-------------------不正确
    <input type="button" onclick="alert('1')">-------------------正确

    双引号中再用双引号要这样:
    var str = "abc\"def\"ghi"
    用反斜杠来禁止解析双引号。

    如果单独用的话,如alert('test')和alert("test")两个根本没区别。

    reply
    0
  • Cancelreply