'JQuery - How to check all value from array before goes to else statement?
How can I check all value from array before going to else statement.
My code only working for the first array, in my case which is /members/
, but it wont work for rest of the array.
if ( jQuery( location ).attr( 'href' ) !== 'https://example.com/' ) {
let getPostType = `<?php echo $post_type = get_post_type($id); ?>`;
if ( getPostType === 'page' ) {
let URLsToAvoid = [ '/members/', '/documents/', '/photos/', '/videos/', '/register/', '/agencies/', '/news/', '/events/' ];
jQuery.each( URLsToAvoid, function( key, value ) {
if ( jQuery( location ).attr( 'href' ).includes(value) ) {
return false;
} else {
let displayHeader = `<?php echo do_shortcode( '[elementor-template id="754"]' ); ?>`;
jQuery( '.container .site-content-grid > div, .container .bb-elementor-content > div' ).prepend(displayHeader);
return false;
}
});
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|