Когда я нажимаю на свои ссылки, используя событие onmousedown, мне нужно дважды щелкнуть по ним, чтобы они переключались. Я не понимаю, почему это так.переключается только при двойном щелчке
function toggleInteractContainers(x) {
//the 'x' variable represents the add friend/message container value
if($('#'+x).is(":hidden")) {
//if the container is hidden then we will slide it down and show it
$('#'+x).slideToggle(400);
} else {
//if its not being hidden then we will hide it
$('#'+x).hide();
}
//this just means we have to hide all the containers
$('.interactContainers').hide();
}
Я звоню его из этого Div
<div class ="interactionLinksDiv">
<a href="#" onclick="return false" onmousedown="toggleInteractContainers('add_friend');">Add Contact</a>
</div>
<div class ="interactContainers" id ="add_friend">
<div align ="right"><a href="#" onclick= "return false" onmousedown = "toggleInteractContainers('add_friend')">cancel</a></div>
Add as a contact?
<a href ="#" onclick="return false" onmousedown="javascript:addAsFriend(); ">Yes</a>
</div>
Я не получаю никаких ошибок, которые расстраивают. Я был бы очень признателен, если бы мне сказали, почему это произошло, и что я могу сделать, чтобы это не повторилось. Любые советы по программированию на этом пути также были бы замечательными.
сценарий перестает работать вообще @cale_b – Octavius