I have noticed that while using almost all standard CSS ID selectors, we get an element example with jQuery such as $ ("#myElement")
. My priority only references the element such as $ (myElement)
I have seen a difference between the two, and so on, when the element is directly referred to an element in the context of an element, the element will not be found; Using the CSS ID selector will get the element every time.
Why should I use one another?
The difference is that the $ ('# MyElement')
string selector Creating a jQuery Object Using In this case, it will create an object from the DOM element which will be id
like myElement
.
On the other hand, it will be a string that creates a jQuery object from $ (MyElement)
whichever value is stored in the myElement
variable. It may be another jQuery object, such as "# myElement"
, or it may be a native JS domain, though it does not make any sense and should be avoided.
For more information
No comments:
Post a Comment