jQuery How To Fix the “$ is not a function” Error Using noConflict

jQuery How To Fix the “$ is not a function” Error Using noConflict

As we know that jQuery uses the $ sign as a shortcut and what will happen if other JavaScript frameworks use the same shortcut.

In that scenario, it giving error “$ is not a function” due to conflication with other libraries.

To avoid the conflicts with other libraries you can remore $ sign with jQuery but its very difficult to remove from everywhere so you can fix this error by using the jQuery noConflict() method.

You can also define your own shortcut because noConflict() method returns a reference to jQuery which you can hold in your custom variable.

  1. $.noConflict();
  2. jQuery(document).ready(function(){
  3. jQuery("a").click(function(){
  4. jQuery("p").text("Its working!");
  5. });
  6. });
Create alias to jQuery function

Here i create $jq alias to jQuery function.

  1. var $jq = jQuery.noConflict();
  2. $jq(document).ready(function() {
  3. $jq( "div" ).text('Welcome to ExpertPHP');
  4. });
Use short and clear syntax for the DOM ready Function

  1. jQuery(function($){
  2. // Your can write here your jQuery code by using the $
  3. });

Phone: (+91) 8800417876
Noida, 201301
Attention Required! | Cloudflare

Sorry, you have been blocked

You are unable to access ressim.net

Why have I been blocked?

This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.

What can I do to resolve this?

You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.