开发者

Ctrl+S Triggers Function but only if inside of specific Text Area JQuery

开发者 https://www.devze.com 2023-04-02 10:06 出处:网络
I want to trigger a javascript function (an Ajax Post save function) when someone presses ctrl + s. But only when they editing a sp开发者_开发百科ecific textarea (with a unique ID)

I want to trigger a javascript function (an Ajax Post save function) when someone presses ctrl + s.

But only when they editing a sp开发者_开发百科ecific textarea (with a unique ID)

So if they aren't "focused" on the text area Ctrl+s should behave like default.


A couple of similar questions:

  • Best cross-browser method to capture CTRL+S with JQuery?

  • CTRL + S to submit form and all inputs

I bet that first one will get you well on your way to coming up with a solution. Just replace $(window) in the sample code in the accept answer with $('#yourtextareaid').

0

精彩评论

暂无评论...
验证码 换一张
取 消