What does the "#" sign mean in JavaScript?

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?

+7
source share
8 answers

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".

+14

jQuery (#) . jQuery . "searchTerm".

id, jQuery JavaScript document.getElementById(), . id, h2 # pageTitle, jQuery , .

, , . , .

id . , , , DOM. , ; .

, , .

: http://api.jquery.com/id-selector/

+10

. # . , $ - jQuery.

, jQuery (, , CSS). # "ID". DOM `searchTerm.

+3

id HTML ( DOM ).

+2

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.

0
source

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

for class <div class="abc">....</div>$(".abc")

0
source

Now # will / may mean private instance fields: https://tc39.imtqy.com/proposal-class-fields/

0
source

All Articles