我想call
a button click
从another button
。所以如果我点击第一个按钮 - 第二个按钮应该触发。我有以下代码。jQuery通话按钮点击其他按钮
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
});
});
链接到我的小提琴:Fiddle
我不能找出IAM做错了 - 可能有人请解释它对我?
我没有看到分配给第二个按钮的任何点击事件。见http://jsfiddle.net/tewathia/y47AL/2/ – tewathia
它工作正常http://jsfiddle.net/y47AL/4/ –
还是你的意思是'点击'的超链接?在这种情况下,尝试:'location.href = $(“#second”)。parent()。attr('href');' – tewathia