I am using wordpress and a plugin called advanced ajax page loader.
http://wordpress.org/extend/plugins/advanced-ajax-page-loader/
I am somewhat familiar with php, javascript and jquery, but not an expert by any means. I have the following block of code that excludes certain pages from loading in ajax and it works great.
jQuery(scope + "a").click(function(event){
//if its not an admin url, or doesnt contain #
if ( this.href.indexOf(AAPLhome) >= 0 && this.href.indexOf('/wp-') < 0 && this.href.indexOf('#') < 0 && this.href.indexOf('/search') < 0 && this.href.indexOf('/2013') < 0 && this.href.indexOf('/2012') < 0 && this.href.indexOf('/2011') < 0 && this.href.indexOf('/feed') < 0 && this.href.indexOf('/portfolio') < 0 && this.href.indexOf('/store') < 0 ){
// stop default behaviour
event.preventDefault();
});
As you can see I am excluding pages with certain strings in their url.
However I need to target the homepage link and by inserting the home url this way, all pages contain the home url so they are all excluded. I want to be able to insert a hasClass statement in this block of code so I can exclude a link that has a class of ‘homelink’.
This following gave me an error of this.hasClass is not a function.
this.hasClass('homelink')
So I must be doing something wrong but I’m darned if I know what.
I have tried looking at these links but didn’t get much out of it.
Jquery hasClass + If Statement
You need to wrap
thisin$()thisin that case is a DOMElement and dom elements don’t have ahasClassmethod. By passingthisto$(), it becomes a jQuery object which does have thehasClassmethod.