JavaScript中的'#'符号是什么意思? [英] What does the '#' sign mean in JavaScript?

查看:117
本文介绍了JavaScript中的'#'符号是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Javascript的新手,我试着理解一些代码。我不明白,我找不到任何关于的文件。

I'm new to Javascript and I'm try to understand some code. I don't understand and I can't find any documentation about the # sign.

$(function () {
      $("#searchTerm").autocomplete({

$(#searchTerm)是什么意思?

What does $("#searchTerm") mean?

推荐答案

在JavaScript中?没什么特别的。它只是字符串的一部分。

In JavaScript? Nothing special. It is just part of a string.

$ 函数可能会对它做一些事情,但很难说 $ 函数是什么

The $ function might do something with it, but it is hard to tell what the $ function is.

有很多库提供 $ 函数,它充当该库的厨房接收器。它们包括< a href =http://www.prototypejs.org/ =noreferrer>原型, Mootools jQuery 。这个看起来最像jQuery,在这种情况下,参数是一个包含 CSS选择器,所以表示<的开始a href =http://api.jquery.com/id-selector/ =noreferrer> id选择器。

There are a lot of libraries which provide a $ function that acts as a kitchen sink for that library. They include Prototype, Mootools and jQuery. This one looks most like jQuery, in which case the argument is a string containing a CSS selector, so the # indicates the start of an id selector.

此选择具有给定id属性的单个元素。

This "Selects a single element with the given id attribute".

这篇关于JavaScript中的'#'符号是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆