I need to 'click' one button using JavaScript, when the user clicks another button.
In Chrome on Mac, the following works fine. However, in Safari on Mac, clicking the button simply reloads the current page, rather than triggering the expected behaviour.
JS
$( 'document' ).ready( function() {
var $myForm = $('#my-form');
$('#button-fake').on('click', function(){
console.log("FAKE CLICKED");
if ($myForm[0].checkValidity()){
console.log("FORM VALID");
$('#button-real').click();
console.log("FORM SUBMITTED");
}
});
});
HTML
<input type="submit" id="button-fake" value="Fake button" />
<input type="submit" id="button-real" value="Real button" />
PS: Not my idea, I just need to get it working.