Jquery second button cannot fire -


i got 2 button below:

<input id="btn_sendmsg" name="send_message" type="button" value="send message 1" /> <input id="btn_sendmsg" name="send_message" type="button" value="send message 2" /> 

when click "send message 1" button, works , fire properly, "send message 2" button doesn't fire @ all, what's issue?

$("#btn_sendmsg").live('click', function(){     parameters = $('#form1').serialize();     alert(parameters); }); 

thanks.

id of element should unique in document, use class instead if want associate same key multiple elements.

if there multiple elements same id id-selector return first element id

<input class="btn_sendmsg" name="send_message" type="button" value="send message 1" /> <input class="btn_sendmsg" name="send_message" type="button" value="send message 2" /> 

then

$(".btn_sendmsg").live('click', function(){     parameters = $('#form1').serialize();     alert(parameters); }); 

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -