Understanding Variable Definitions in jQuery

Asked 1 years ago, Updated 1 years ago, 66 views

I'm studying jQuery.

When defining a variable, the variable name may or may not be $, but
What are the differences?

jquery

2022-09-30 21:43

1 Answers

Although completely optional, you can name variables with the common jQuery instance with $ as a prefix.
This allows you to see at a glance that the variable has a jQuery instance.

Example:

const name='john'
const$foo=$('#foo')

$foo.text(name)


2022-09-30 21:43

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.