0

I have this script in a wordpress website

<script>
  jQuery( function($) {
      jQuery( "#selectable" ).selectable();
  } );
 </script>

All my other scripts work but with this I got TypeError: $(...).selectable is not a function(…). When I use it without wordpress it works perfectly.

1

I always refer to to this blogpost about how to including jQuery code in WordPress. It shows you how to use noConflict within your javascript-code.

var $j = jQuery.noConflict();

    $j(function(){
        // YOUR CODE HERE
    }
}

Also make sure that the jQuery library is included on the frontside of your WordPress installation with the wp_enqueue_script-function. Hope it will work out for you.

  • 1
    jQuery is loaded automatically. No need to enqueue it. – cjbj Nov 11 '16 at 17:49
  • It worked for me. Tank you! – Madalina Ionescu Nov 15 '16 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.