I am create a form in html for submit data. When I shall reach save button by tab press and press tab again then tab will act as a Enter key. That means data will save. How can i do this?
I have use the following code
<form id="form">
<input type="text" />
<input type="text" />
<input type="text" />
<input disabled="disabled" />
<input readonly="readonly" value="readonly" />
<textarea></textarea>
<input type="submit" />
$(":input").on("keydown", function(event) {
if (event.which == 9) {
event.startPropagation();
}
});
Please tell me the solution.
an alternative to mjalajel 's answer
$("input[type='submit']").on("keyup", function(event) {
if (event.which == 9) {
$(this).trigger('click');
}
});
this way whatever you have on click event is called
if you want to follow a link, you have to replace
$(this).trigger('click');
with
this.click();
this is because jquery click event isn't the same as a "real" click more info here: jQuery: how to trigger anchor link's click event
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句