I have this HTML which looks like this:
<input type="submit" name="savebutton" class="first button" /> <input type="submit" name="savebutton" class="second button" />
and JS:
jQuery("input.second").click(function(){ // trigger second button ? return false; });
So how can I trigger the click event from the 2nd button by clicking on the first one? Note that I don't have any control over the 2nd button, neither on the html or the click event on it...
$("#button2"). bind("click", (function () { alert("Button 2 is clicked!"); $("#button1"). trigger("click"); })); When button2 is clicked, the alert message “Button 2 is clicked!” is prompt, follow by button1 alert message “Button 1 is clicked!
private void SubGraphButton_Click(object sender, RoutedEventArgs args) { } private void ChildNode_Click(object sender, RoutedEventArgs args) { // call SubGraphButton-Click(). }
The HTMLElement. click() method simulates a mouse click on an element. When click() is used with supported elements (such as an <input> ), it fires the element's click event. This event then bubbles up to elements higher in the document tree (or event chain) and fires their click events.
jQuery click() Method The click event occurs when an element is clicked. The click() method triggers the click event, or attaches a function to run when a click event occurs.
Add id's to both inputs, id="first" and id="second"
//trigger second button $("#second").click()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With