Hash sign in jQuery calls

后端 未结 1 1955
广开言路
广开言路 2021-02-08 12:54

Being a pragmatic coder I tend to miss some obvious things and I wonder, What\'s the difference between

$(\'loc\')
$(\'#loc\')

The more info th

相关标签:
1条回答
  • 2021-02-08 13:07

    $('loc') is an element selector, looking for <loc> elements.

    $('#loc') is an #id selector, looking for id="loc" elements.

    Think CSS when looking at almost all jQuery selectors, they're very close if not identical in most cases.

    0 讨论(0)
提交回复
热议问题