Hash sign in jQuery calls

后端 未结 1 1938
广开言路
广开言路 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 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)
提交回复
热议问题