jQuery MiscLesson 29Free preview
jQuery noConflict()
This lesson is part of jQuery · All levels
Summary
The noConflict() method is used when the $ symbol clashes with other libraries that also use it, such as a graphics library or an old framework. This method removes the $ ownership so that it can be returned to the previous owner, and then you save jQuery to its own variable. That way jQuery can still be used with other libraries on the same page.
Key points
- NoConflict() remove the $ alias belonging to jQuery
- The result of the call is stored in a variable, e.g. var jq = $.noConflict();
- Then jQuery is written with a new variable, not $
- The clashes occurred when two libraries were using $
- The freely substituted variable is named according to project requirements
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.