trigger button click
Tagged: button
- This topic has 1 reply, 2 voices, and was last updated 11 years ago by soundanalogous.
-
AuthorPosts
-
March 28, 2012 at 12:13 AM #596lunchboxParticipant
hi there,
I’m looking at how to click an html button using button connected to arduino. I know it sounds silly, but couldn’t get it to work. I modified the getting started example like this:
function onButtonRelease(event) {
// get a reference to the button object that fired the event
var btn = event.target;
$(‘#button’).html(“button: pin = ” + btn.pinNumber + ” released”);
$(‘button’).trigger(‘click’);
}where on the html i have the button tag
It didn’t work. Anybody has solution for this? Cheers 🙂
March 28, 2012 at 1:01 AM #600soundanalogousMemberIn order for the jQuery trigger() method to work, you need to create a click handler somewhere in your code. So you need both:
// put this at the end of the onReady() method
$(‘button’).on(‘click’, handleClick);// now trigger should work in the onButtonPress or onButtonRelease methods
$(‘button’).trigger(‘click’); -
AuthorPosts
- The forum ‘Forum’ is closed to new topics and replies.