If we just declare both jQuery and Prototype on the same page like so:
When you call jQuery.noConflict(), it gives control of the $ variable back to whomever implemented it first. Once you free up the $ variable, you only will be able to access jQuery with the jQueryvariable. For example, when you used to use $("div p"), you would now use jQuery("div p").
The jQuery library and virtually all of its plugins are constrained by the jQuery namespace. You shouldn’t get a conflict with the jQuery variable and any other library (i.e., Prototype, YUI, etc.). jQuery does however use $ as a shortcut for thejQuery object. This shortcut definition is what conflicts with other libraries that also use the $ variable. As we’ve seen in the solution, we can free jQuery of the $ shortcut and revert to using the jQuery object.
There is another option. If you want to make sure jQuery won’t conflict with another library but still have the benefit of a short name, you can call jQuery.noConflict() and assign it to a variable:
You can define your own short name by choosing the variable name you assign,
Finally, another option is to encapsulate your jQuery code inside a closure:
By using a closure, you temporarily make the $ variable available to the jQuery object while being run inside the function. Once the function ends, the $ variable will revert to the library that had initial control.
J Query Related Interview Questions
|HTML 4 Interview Questions||HTML Interview Questions|
|HTML 5 Interview Questions||Zend Interview Questions|
|JqueryUI Interview Questions||Dynamic HTML Interview Questions|
|XQuery Interview Questions||jQuery Mobile Interview Questions|
J Query Related Practice Tests
|HTML 4 Practice Tests||HTML Practice Tests|
|HTML 5 Practice Tests||Zend Practice Tests|
|PHP and Jquery Practice Tests||J Query Practice Tests|
|CodeIgniter Practice Tests||Dynamic HTML Practice Tests|
J Query Tutorial
Selecting Elements With Jquery
Beyond The Basics
Faster, Simpler, More Fun
Html Form Enhancements From Scratch
Html Form Enhancements With Plugins
Interface Components From Scratch
User Interfaces With Jquery Ui
Jquery Ui Theming
Jquery, Ajax, Data Formats: Html, Xml, Json, Jsonp
Using Jquery In Large Projects
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.