I'm trying to toggle my search bar, for that I've a href tag and font-awesome icon.
Trigger works well when it is index.php, I mean home page.
It creates independently links to other pages and to home.
Trigger doesn't work when other pages is loaded ecxept home page.
I would like to disable it to be create or recognize other pages URL and to use it only for trigger for toggle.
For example: this script works only when my site's URL mywebsite.com is, but It won't work when URL so "mywebsite.com/a-random-page" is.
HTML
div class="messagepop pop">
<?php get_search_form(); ?>
</div>
<a href="#" id="contact"><i class="fa fa-search"></i></a>
jQuery
// Show mobile-menu > 700
$(window).resize(function() {
if ($(window).width() > 800) {
$(".messagepop").hide();
}
});
function deselect(e) {
$('.pop').slideFadeToggle(function() {
e.removeClass('selected');
});
}
$(function() {
$('#contact').on('click', function() {
if($(this).hasClass('selected')) {
deselect($(this));
} else {
$(this).addClass('selected');
$('.pop').slideFadeToggle();
}
return false;
});
$('.close').on('click', function() {
deselect($('#contact'));
return false;
});
});
$.fn.slideFadeToggle = function(easing, callback) {
return this.animate({ opacity: 'toggle', height: 'toggle' }, 'fast', easing, callback);
};