The issue I'm having is that this RPG that I play on has an image inside of the button, literally. And I have no idea how I can simulate a click in Javascript with this.
This is the HTML of the button.
<button class="forward inputsubmitflex" onclick="return do_attack(this, event.clientX, event.clientY, event);"><img src="/images/icons/RubyHoundour.png">Fight</button>
I've tried the following snippets of code to try to click this button, but they haven't worked.
$( ".forward inputsubmitflex" ).click(function()
That didn't work though.. so I have no idea what to do.. D: Here is how the button looks, if it helps at all.
https://i.sstatic.net/8xhOP.png
^That's a picture of the button. :c
Any help at all? I'm willing to do this in jQuery, as I posted my jQuery snippet above, but I'd prefer Javascript..
You are quite close, the space in the selector is what is messing it up. You would need to do:
$(".forward.inputsubmitflex").click(function()
Here is a Fiddle: http://jsfiddle.net/mifi79/LNa9R/
If you are just trying to trigger the click event, you should use this:
$(".forward.inputsubmitflex").trigger("click");
Although, clicking on the button will automatically fire the onclick event. If you are trying to trigger the button by clicking elsewhere this Fiddle should help: http://jsfiddle.net/mifi79/LNa9R/3/