jQuery Call Button Click from other Button -


i want call button click another button. if click first button - second button should trigger. have following code.

html:

<input type="submit" name="savebutton" id="first" /> <a href="http://www.google.com/">  <input type="submit" name="savebutton" id="second" /> </a> 

jquery:

$(function(){   $('#first').click(function() {    $("#second").trigger('click'); // $('#second').click(); wont work either   }); }); 

link fiddle: fiddle

i cant figure out iam doing wrong - can 1 please explain me?

it works don't have handler on second! click event got fired don't should happen...

here code example , fiddle

$(function(){     $('#first').click(function() {         alert('button clicked');         $("#second").trigger('click');     });      $("#second").click(function() {        alert('button 2 clicked!');     }); }); 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -