I am new to Javascript and I am trying to understand some kind of code. I do not understand, and I can not find the documentation for the sign #.
#
$(function () { $("#searchTerm").autocomplete({
What does $ ("# searchTerm") mean?
In javascript? Nothing special. This is just part of the line.
A function $can do something with it, but it's hard to say what a $function is .
$
, $, . Prototype, Mootools jQuery. , , # id.
" id".
jQuery (#) . jQuery . "searchTerm".
id, jQuery JavaScript document.getElementById(), . id, h2 # pageTitle, jQuery , ., , . , .id . , , , DOM. , ; ., , .
id, jQuery JavaScript document.getElementById(), . id, h2 # pageTitle, jQuery , .
, , . , .
id . , , , DOM. , ; .
, , .
: http://api.jquery.com/id-selector/
, , jQuery ID
http://api.jquery.com/id-selector/
. # . , $ - jQuery.
, jQuery (, , CSS). # "ID". DOM `searchTerm.
id HTML ( DOM ).
Javascript! jQuery!
In jQuery, you can select elements using CSS style selectors. In this case, it #xis a CSS selector to select all elements with an identifier x.
#x
x
This is the identifier of the element, for example: `...
When you need to access this div using JS or jQuery, just name it $("#xyz").do something
$("#xyz")
for class <div class="abc">....</div>→$(".abc")
<div class="abc">....</div>
$(".abc")
Now # will / may mean private instance fields: https://tc39.imtqy.com/proposal-class-fields/