Where to Insert Custom jQuery Javascript

I’m wanting to insert custom jQuery to run when the header loads, and then when clicking an element in my header. I’m running X pro. How should I insert this code? Also, is using $ acceptable?

$( document ).ready(function() {
PhoneButtonClick(“Load”);
});

$( “#phonebutton-anchor-button” ).click(function() {
PhoneButtonClick(“Test”);
});

$( “#phonenumber” ).click(function() {
PhoneButtonClick(“Hide”);
});

function PhoneButtonClick() {
$( “#phonenumber” ).toggleClass( “hidden” );
};

Hi there, You need to wrap all your code inside the block below to be able to use $:

jQuery( document ).ready(function($) {
});

I am not sure if it will serve your purpose, but always make sure that you wrap your code around the block I have mentioned to avoid jQuery conflicts.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.