Reputation: 435
The problem is when I press left-nav "a" element it should show()
me the div element, but its going to hide()
it automatically. The "a" element is created with php and it has href of ?id=$product
, when I press class closebtn
"a" element in side my navbar it show()
's me the div.
JavaScript:
$(document).ready( function() {
$(".sisu").hide();
$('.vasaknav a').click( function() {
$(".sisu").show();
});
});
PHP:
<?php
$kask=$yhendus->prepare("SELECT id,Product from store GROUP BY Product");
$kask->bind_result($id, $Product);
$kask->execute();
while($kask->fetch()){
echo "<a href='?id=$Product' style='color:red;'>".htmlspecialchars($Product)."</a>";
}
?>
HTML:
<div id="Myvasaknav" class="vasaknav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<?php require('php/navlist.php'); ?>
<a href=# >test</a>
</div>
<span style="font-size:30px;cursor:pointer" onclick="openNav()" id="click">☰</span>
Upvotes: 1
Views: 55
Reputation: 54841
To prevent default action when clicking <a>
(which is reloading page / redirecting elsewhere) you should change your code like:
$(document).ready( function() {
$(".sisu").hide();
$('.vasaknav a').click( function() {
$(".sisu").show();
return false; // prevent default action
});
});
With this you will stay on the same page and .sisu
element will be shown.
Upvotes: 0