I am trying to handle the case where someone presses ENTER on any <textarea> on my page. Not all of the <textarea>‘s are on the page when it loads (they can be added dynamically through user events), so I don’t know each <textarea> id at page load (and therefore can’t use jQuery to listen to each event by id). I also tried to use the JS onkeydown event, but I haven’t been able to find a way to detect which key caused the onkeydown event to fire.
So, is there a way to handle all <textarea> keydown’s on my page, along with which key caused the event, or is there an elegant solution I seem to be missing? Some global event?
Use
delegate. You can specify thebodyor anycontainerwhich will hold all these dynamic textareas.