-2
I have a script that shows a div I currently have to show when I click and hide when I click but I want when opened the user when click on any part of the page hide the div someone can give a help ?
Jquery
$(document).ready(function(){
$("body").click(function(){
$('#opcoes-'+id_agente+'').hide();
});
$("body").on('click', '#botao_ver_opcoes', function(e) {
var id_agente = $(this).data("id-agente");
$('#opcoes-'+id_agente+'').toggle();
event.stopPropagation();
});
$('#opcoes-'+id_agente+'').hide();
});
HTML
<div id="opcoes-{{ $agent_tree->user_id }}" style="width: 130px; margin-top: 30px; background-color: white; border: 1px solid #c2c5cd; z-index: 10; position: absolute; display: none; border-top: none;">
<!--<div data-toggle="modal" data-target="#modal-add-credito" id="add-credito-btn" data-id-agente="{{ $agent_tree->user_id }}" data-id-line="{{ $agent_tree->credit_line }}" style="text-align: center; line-height: 30px; cursor: pointer;">TRANSFERIR</div>-->
<div data-toggle="modal" data-target="#modal-info-agente" id="info-user-btn" data-id-agente="{{ $agent_tree->user_id }}" style="text-align: center; line-height: 30px; cursor: pointer;">INFORMAÇÕES</div>
<!--<div data-toggle="modal" data-target="#modal-update-senha" id="change-pwd-btn" data-id-agente="{{ $agent_tree->user_id }}" style="text-align: center; line-height: 30px; cursor: pointer;">SENHA</div>
<div style="text-align: center; line-height: 30px; cursor: pointer;">MENSAGEM</div>-->
</div>
Thanks for the answer already tested but only hides clicked on the button if click on any part of the page does not close keep open the div
– César Sousa
I edited the answer with an example because your HTML was missing from the question
– user60252
OK I’ve put html now refocus the answer if please based on what I have so that later I can give your answer as sure
– César Sousa
this id="options-{{ $agent_tree->user_id }}" of the div you have to put in place of #login-panel
– user60252
The problem is that I am saving the user_id astraves of an assigned date as I can spend when I click so off the page or it will not know which to close
– César Sousa