- This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › jQuery/WordPress Help
Hello to all.
I’m getting started with jQuery (Kinnda) and I ran into some trouble of course. I have a Page in which a bunch of divs get shown/hidden with jQuery.
It works fine locally but once I take my html to wordpress it just stops working. I tried everything from placing the code in the footer.php in the header.php and in and external .js file loaded from the functions theme and I get the same result:
$ in not a function
I have other js code working correctly with the jQuery(document).ready(function($){ but this one is driving me crazy.
Here’s my code
jQuery.noConflict();
jQuery(document).ready(function($){
$(".frase1").hide();
$(".fr1").show();
$('.fr1').click(function($){
$('frase1').slideToggle();
});
$(".frase2").hide();
$(".fr2").show();
$('.fr2').click(function($){
$(".frase2").slideToggle();
});
$(".frase3").hide();
$(".fr3").show();
$('.fr3').click(function($){
$(".frase3").slideToggle();
});
});
I know the problem is on the second $ of
$('.fr1').click(function($){
$('frase1').slideToggle();
});
but I don’t know how to fix it.
Thank you before hand for the help
Azul
Just so this question doesn’t stay unsolved, the problem was that the click event is called with the clicked element as the parameter but I was overriding $. Removed the $ and it worked:
Copy code
$(‘.fr1’).click(function(){ $(‘frase1’).slideToggle(); });