I'm replacing class name generated by one of the plugins with mine. I found this easier than fiddling with plugin on every upgrade. Anyways, in WP this simply doesn't do anything! When I test it on non wp (same template xhtml) it works!
what could be the conflict? I have jquery included.
$(document).ready(function(){
$(".slideright img").removeClass("ngg-singlepic").addClass("cover");
//$(".ngg-singlepic").addClass("cover");
});
2 Answers 2
Try this:
jQuery(document).ready(function($){
$(".slideright img").removeClass("ngg-singlepic").addClass("cover");
//$(".ngg-singlepic").addClass("cover");
});
The problem is that I think wordpress includes other libraries that conflict with the $ when used with jquery.
To get around this you need to explicitly call jQuery the first time and if you pass $ into the function then it will let you use the familiar $ within the scope of the jquery function.
Hope that helps.
2 Comments
jQuery(document).ready(function($){...}); now, even outside of wordpress. Just incase in the future compatibility is needed with other libraries. :) Its a good habit to get into I think. :)Maybe there is some other framework included in your page. Try the following:
jQuery( function($) {
$(".slideright img").removeClass("ngg-singlepic").addClass("cover");
});
And if that does not help, you can even try to put jQuery.noConflict(); before the snippet.