tery.blargh tery.blargh - 1 year ago 37
jQuery Question

How to programmatically click on a text input using JQuery?

I'm trying to implement a messaging application in my game, so instead of clicking on the input text field manually, I want users to only press "enter", write something, then press "enter" again to submit.

For some reason, when I do this (press "enter"), the

alert fires from the input, but the input stays the same, I am still not able to type into the input form. If I manually click it, it works fine.

Am I missing something?


<form id="messageInput" action="">
<input id="m" autocomplete="off" maxlength="100" onclick="alert('clicked')"/>


keyOn["enter"] = false;



Answer Source

Thank you all for your help, but I somehow found the solution by randomly checking everything I saw:


Use focus instead of click

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download