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('#lang option[value=zh-TW]').attr('selected','selected');

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:


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.

  • 1
    It looks like you don't have button with ID "login". You could fire an event with following line: jQuery('.loginbtn').click(); Commented May 7, 2015 at 9:34
  • @SahilPurav Thanks, this jQuery('.loginbtn').click() worked for me. You may consider add it as an answer.
    – Hawk
    Commented May 12, 2015 at 9:09
  • Glad I helped you. Please accept my answer so that it will be helpful for other googlers. Commented May 12, 2015 at 9:16

2 Answers 2


Try this:

  • For multiple reasons, it would be better to avoid try this / code-only answers. You see, 1. It is bad role modeling - future volunteers will see that this type of answer can win the green tick 2. Code-only answers do very little to educate/empower the asker 3. Existing pages are used to close new duplicate questions, so your answer is very unlikely to only "speak" to one person with this issue. Please reinforce this answer with some explanation of what it does, how it works, why you chose it, etc. and perhaps a hyperlink to a credible source. Commented Feb 1, 2019 at 12:15

You need to trigger submit on form for login user.

edit: did not see You don't have a login id in your div. so try this:


and if this not work for you try this:

  • Your answer is very short and I'm not sure if I understand it. How can I trigger login form submission?
    – Hawk
    Commented May 7, 2015 at 9:14
  • He answered correctly. You cannot downvote this answer as you indeed do not have button with "login" as ID. Commented May 7, 2015 at 9:36
  • +1, I just made a small edit and used jQuery rather than $ as the OP isn't currently using any alias ;)
    – Lodder
    Commented May 7, 2015 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.