'Preventing losing focus when showing an element with jquery show
I'll try the best to be as mutch clear as possible.
I've an element with a click handler attached via jquery, let's call this element "e1". When "e1" is clicked, the handler call a show() on another element, let's call this "e2".
The problem is that when i made a click, "e2" grab the focus. Instead of this, I want "e2" to show but "e1" to maintain the focus.
This is the click handler:
$('#tabella_visite').on( 'click', '.selezione_calcolo_appuntamenti', function () {
var elemento = $(this);
var codice_visita = elemento.attr('codice_visita');
elemento.toggleClass('bg-info selezionato');
if(elemento.hasClass('selezionato')){
$('#calcolo_appuntamento_massivo form').append('<input class="input_appuntamento_selezionato" id="input_appuntamento_selezionato_' + codice_visita + '" type="hidden" name="visite[]" value="' + codice_visita + '">');
}else{
$('#input_appuntamento_selezionato_' + codice_visita).remove();
}
gestioneTastoCalcoloAppuntamentoMassivo();
} );
This is the function performing the show:
function gestioneTastoCalcoloAppuntamentoMassivo(){
var selezionati = $('.input_appuntamento_selezionato');
$('#contatore_calcolo_appuntamento_massivo').html(selezionati.length);
if(selezionati.length > 0){
$('#calcolo_appuntamento_massivo').show(200);
}else{
$('#calcolo_appuntamento_massivo').hide(200);
}
}
(In other word I want the element with "selezione_calcolo_appuntamenti" class to maintain focus after the execution of "gestioneTastoCalcoloAppuntamentoMassivo" fired by clicking on it)
How can I maintain focus on "e1" while showing "e2" ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
