The following script was found on StackOverflow. It is suppose to simulate a button click with the up-tick of an Enter key.
$("#id_of_textbox").keyup(function(event) {
if (event.keyCode === 13) {
$("#id_of_button").click();
}
});
Now, I am not using it for a textbox, but for a search box. In order to get it to work I have tried the following:
Used the <form> element as the selector for the keyup() function.
Used the <input> element of the search
We are making progress -- sort of. For, implementing the following strategy
$("REFERENCE TO FORM").on("submit", function(e){
// Stop the form from reloading the page
e.preventDefault();
// Do action "X" here:
performActionX();
});
results in a successful ENTER/RETURN form submission, but results in a failed button click.
(function() {
// $('.error').hide();
// $(".SearchButton").click(function() {
$('#qa_searchform').on('submit', function(e) {
e.preventDefault();
var search