I wrote jquery code previously wich worked fine until now. Now suddenly it started to behave in strange way.
$(document).ready(function(){
$("#head").click(function(){
$(this).next().toggle('slow');
});
This code above is supposed to toggle the contents under the head bar. It was working fine. Now it slides down and then slides up on single click, which means it is getting fired twice, which in turn I suspect to be because of first capturing
phase and then bubbling
. So it gives this swing effect. So my question is this: is this possible to be fired in the way I suspect this to be? Bubble and Capture?
Edit
This problem started after I included this code
$('#inputsearch').keyup(function(event){
var searchterms=$('#inputsearch').val();
console.log(searchterms);
$.ajax({
type:'POST',
data:{'searchterms': searchterms},
url:'displaysearch.php',
success: function(response){
$("#searchingresults").empty().html(response).show();if(searchterms=='')
{$('#searchingresults').empty().hide();}
}
});
event.stopPropagation();
});
$('html').click(function(){ if(!$(event.target).is('#inputsearch')){
$('#searchingresults').empty().hide();
}});
The html
<div align="left" id="head" style="margin:3px; margin-top:5px;">Contents <span style="padding-right:70px; font-size:10px;"> 7 </span></div>
<div align="left" id="subbox" style="position: absolute; width: 100%; display: none;">
<ul><li><a href="/spiralblog/home.php">askbuddy</a></li>
<li><a href="/spiralblog/home.php">PHP</a></li>
<li><a href="/spiralblog/home.php">CSS</a></li></ul>
</div>