I have a js file which has several fn() and it was working fine but when at tached a js plugin file, i get error in firebug.
$(document).ready(function() {
var innerHTML = $("#id_1").html();
$("#Id_2").html(innerHTML)
});
above fn() was working but now i am getting error in firebug $("#id_1") is null.
if i use jQuery instead of $ then it's workin fine. please see below the corrected function.
$(document).ready(function() {
var innerHTML = jQuery("#id_1").html();
jQuery("#Id_2").html(innerHTML)
});
now my problem is, i have several js files and i have used $ and now i might have to change $ to jQuery. please give me any idea to avoid this.
The extra library you are using (wysiwyg.js) is also declaring a function $():
/**
* Get an element by it's identifier
*
* @param id Element identifier
*/
function $(id) {
return document.getElementById(id);
}
You should use jQuery.noConflict()
$ is just an alias for 'jQuery' .
Please make sure the library you are adding is not making any conflict with '$' . It generally happens when you try adding another framework with '$' as alias ex prototype.
use jQuery no Conflict http://api.jquery.com/jQuery.noConflict
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With