How to use Jquery in the JS tab?

Hello. I have a small bit of jquery code I am trying to use in the Javascript tab (JS) in X-Pro, but cannot get it to function. When I place the code below in a .html file, made with a text-editor, it works perfectly. Any idea?

$( “#virtual-poss” ).click(function() {
$( “#virtual-poss-txt” ).toggle( “slow”, function() {
});
});

Hi @mcaravaglia,

Thanks for reaching out!

The jQuery is valid and I am not sure why it is not working on your end! You can probably try adding it inside a document ready function. Please check the code below.

jQuery( document ).ready(function( $ ) {
    $( "#virtual-poss" ).click(function() {
		$( "#virtual-poss-txt" ).toggle( "slow", function() {
		
		});
	});
});

Please note that custom JS code is outside the scope of our support. Issues that might arise from the use of custom JS code and further enhancements should be directed to a third-party developer or you can avail One where we can answer questions outside of the features of our theme.

Hope that helps.

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