I'll buy you a beer via Paypal if you can help me out! I have been stuck with this problem for hours, please hear me out.
I am using a live search on my site. When the visitor types something into the form on the index.php page, the form either gives out results or in case nothing is found in the database, it outputs a button instead on the index.php page under the form via echo function. (the page where the search form is ran from is search.php).
That means this button (under the id #Ne) is not on the index.php page HMTL but is echoed through search.php on to the index page.
What i am trying to do is to hide the search form with one of the buttons. The search form is on the index.php page under the id #iskanje.
This is the javascript I am using. If i put this script on the index.php page nothing happens, and if i put it on the search.php page it crashes the whole search form.
<script>
$( "#Ne" ).click(function() {
$( "#iskanje" ).hide( "slow" );
});
</script>
This is the HTML on the index.php page:
<div id="iskanje" class="arcus-content divider-2">
<div id="main">
<div class="row services-i ">
<!-- Naslov -->
<div class="icon"></div>
<h5 class="title">Za katero vrsto storitev bi radi oddali vaše povpraševanje?</h5>
<!-- Input -->
<input type="text" id="search" autocomplete="off">
<!-- Rezultati -->
<h4 id="results-text"> <b id="search-string"></b></h4>
<ul id="results"></ul>
</div>
</div>
</div>
This is some excerpts from the search.php page:
$text = '<button id="Ne"><i class="icon-white"></i>Želim oddati povpraševanje</button>';
and this is the whole echo in case results are not found.
echo($output . " " . $text);
I hope I have been clear enough. I can even provide the source files if you can help me out with this.
I have also tried
$( document ).ready(function() {
$( "#Ne" ).click(function() {
$( "#iskanje" ).hide( "slow" );
});
});
Thanks!