How can I solve this query, jQuery won't execute, even with .noConflict();?

584    Asked by NishimuraAsato in Salesforce , Asked on Aug 16, 2021
 I've googled this extensively and still can't debug the issue - I'm setting var $j = jQuery.noConflict();, I've verified that the js and css files are loading properly on the page. Can anyone see what I'm doing wrong here? I'm also using bootstrap but it's working fine and I assume that wouldn't cause a conflict. Following this example.

Includes:

<link href="{!URLFOR($Resource.jQueryUI, 'jquery-ui-1.11.4/jquery-ui.min.css')}" rel="stylesheet" />  

The script:

[removed] var $j = jQuery.noConflict(); j$(document).ready(function(){ j$("#ninjaLink").click(function() { alert("NINJA STAR TO FACE!!!!!"); }); }); [removed] NINJA ATTACK!

Just to verify the files are loading, this is right from the page (both jquery.js and jquery-ui.min.js are loaded, as well as the css): enter image description here


Answered by Owen Welch

The main problem is that you have created a variable $j in your jquery noconflict but you have used j$ in the script to access DOM elements in the query. Just change the variable name to j$ and that should start working.



Your Answer

Interviews

Parent Categories