I want to stimulate the effect of clicking on button (submit button) through javascript or jQuery in a form.
I tried using .click() in jQuery but got no as such response.
In FireBug Events, I get the following events on the submit button of the form.
mouseup { return fn.apply(object, args); }
function () {
return fn.apply(object, args);
}
mousedown { return fn.apply(object, args); }
function () {
return fn.apply(object, args);
}
Well I don't know if this information was useful anyway because both mouseup and mousedown seem to be same here.
The source of submit button appears like:
<input type="submit" name="submit" id="submit" value="Submit" />
I have tried other methods to submit the form like .submit() but they did not work. I guess I am left over with stimulating click of button only.
Code:
$('#answer').val("chicago");
$(form).submit();
<form id="level" method="post">
<br/>
<label for="answer">Answer:</label>
<input type="text" name="answer" id="answer" />
<input type="submit" name="submit" id="submit" value="Submit" />
</form>