[jQuery] Associate an event handler to an element out of $(document).ready
Hi JQueriers,
I have a question for you. Well, my problem is the following:
In .js file and inside $(document).ready, I have the following
code:
$(document).ready(function() {
....
$('#menu').find('a').eq(0).click( function ()
{
$('#content').load('html/senas_identidad.html');
}
);
...
Well, when I click on the first link of the menu div, the hmtl file
"senas_identidad.html" loads correctly inside the content div.
The content of "senas_identidad.html" (stupid content) is:
<h1>Señas de iasdfasdasddfsadfs</h1>
<input type="button" title="Publicar novedades seleccionadas"
value="Publicar" name="Publicar" />
<input type="button" title="Publicar novedades seleccionadas"
value="C" name="Publicar" />
hola
Now, I would like that when the user presses the button which value
is "Publicar", an alert message is shown.
First I tried putting the following code inside $(document).ready:
$(document).ready(function() {
...
$('#content').find('input[@type=button]
[@value=Publicar]').click( function ()
{
alert('Hola caracola');
}
);
...
But it doesn't work. It doesn´t execute. I think that has sense
because $(document).ready function only executes when the page is
being loaded and it's ready to be manipulated.
Secondly, I tried to put the same code but out of $
(document).ready:
$(document).ready(function() {
....
});
$('#content').find('input[@type=button]
[@value=Publicar]').click( function ()
{
alert('Hola caracola');
}
I don't know if it is correct but it doesn't work.
Any ideas of how can I associate a click event handler on button which
value is "Publicar"?
Thanks a lot!!!
P.D. : I am a javascript and JQuery newbie, so sorry if it is a stupid
error.