JavaScript / JQuery
May 7, 2021 12:00 AM
Hi there - I need a bit of a push in the right direction.
Situation: Trying to run JQuery command but I am getting the $ is not a function error when previewing in a browser.
Process:
- Add OnShowRunJS to the page level with the following code: $(".accordian").first().addClass("current");
- Preview in Chrome Browser
From my understanding and the photos below, I do have JQuery available to use.
Am I wrong in assuming that JQuery can be used with a OnShowRunJS action?
Solution
You can use jQuery in a Run JS action, but they've changed the "$" with "triv$" to avoid conflicts in case you wanted to integrate a newer version, so triv$(".accordian").first().addClass("current"); should work.
Discussion (2)
You can use jQuery in a Run JS action, but they've changed the "$" with "triv$" to avoid conflicts in case you wanted to integrate a newer version, so triv$(".accordian").first().addClass("current"); should work.
Well that resolved my problem. Now I have to do some JQuery work. Appreciate the insight and education as always @timk !!!