activar un clic al cargar la aplicación
Frecuentes
Visto 54 veces
0
I need to trigger a click on "Home" button on loading the app. Home should become red and it should show the corresponding paragraph in rectangle.
$(document).ready(function(){
$('.showSingle').click(function () {
$('.targetPara').hide();
$('#p' + $(this).attr('target')).show();
$('.showSingle').removeClass('selected')
$(this).addClass('selected');
});
});
var active_link = 1; // Change this value to set the active link
$('td[target='+active_link+']').trigger('click');
I an using the abobe jquery code. Pls help me to figure out what is the prob
2 Respuestas
1
Tu llamada a trigger
necesita estar adentro document.ready
. You're accessing the DOM, so you have to wait for the browser to parse it. Also, make sure you set up the click
event handler before you try to trigger the click
. ¡Espero que esto ayude!
Respondido 28 ago 12, 11:08
0
Maybe the below selector doesn't have "showSingle" css class on it?
$('td[target='+active_link+']')
And what Abraham said (:
Respondido 28 ago 12, 11:08
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas jquery html css or haz tu propia pregunta.
Is this the actual code? If so, you aren't triggering the event on
document
ready, so nothing will happen because the relevanttd
aún no existe. - lonesomeday