For testing purposes on joomla default login file here: (/templates/theme718/html/com_users/login/default_login.php), I run the following successfully to generate the username and change the language
jQuery(document).ready(function(){
....
jQuery('input#username').val('"+username+"');
jQuery('#lang option[value=zh-TW]').attr('selected','selected');
jQuery('#lang').change();
...
})
The code generate username into input username field, changes the language from select box.
However, one thing I could not perform following the same logic. That is, triggering 'login' button to be programmatically 'clicked'. I tried the following lines:
jQuery('#login').trigger('click');
jQuery('submit#login').click();
Nothing fired. I have this line in the file:
<button type="submit" style="float:right" class="button loginbtn""><?php echo JText::_('JLOGIN'); ?></button>
So my question, how to fire click event on login button.
jQuery('.loginbtn').click()
worked for me. You may consider add it as an answer.