質問

Hey all i hardly ever use mootools for a website but i am in need of having a way to programmatically click on a button within a website using mootools.

The website loads the following mootools:

 mootools-core-1.4.5.js
 mootools-more-1.4.0.1.js
 mootools-more-form-1.4.0.1.js

The HTML for the button is this:

<div id="login-submit-action" class="unselectable form-action">
   <button type="submit" class="submit-2013"><span>Sign in</span></button>
</div>

I know how to accomplish this using Jquery:

$('.submit-2013').click();

Any help would be great!

役に立ちましたか?

解決

Try this:

Option 1 / Fiddle 1

document.getElement('.submit-2013').click(); // not cross browser

Option 2 / Fiddle 2

var form = document.getElement('form');
form.fireEvent('submit'); // depends if there's a event.stop etc, may need to stub
// or simply form.submit()
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top