I have a form which as two buttons: cancel and submit
Here is an example page: http://www.problemio.com/problems/problem.php?problem_id=228
If you log in with this login: testing@problemio.com / testing
and then click on the comments tab, you will see some options to edit some of the comments. If you click edit, you get a form. How do I place the submit and cancel on the same line? And how do I k know which of the buttons was clicked?
I try to tell with this:
$('#add_comment').live('submit',function( )
{
alert($(this).val());
...
But that code doesn't output anything for me.
Or maybe in case they press cancel another function can be called altogether?
Thanks!
Buttons don't submit, they click. Forms submit. Just use type="button". You can give the button an ID and read it back as an attribute.
$('#add_comment').live('click',function( )
{
alert($(this).val());
alert($(this).attr('id')
...
完成您的操作后,您是否不能仅绑定到取消按钮的click事件处理程序并停止事件传播?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.