I am using this for catch paste evente on a textarea :
$('textarea#id').on('paste', function (event) {
alert('paste !');
});
It work fine on the page where the texteara is but it doesnt work if textarea#id is not already on the page, if I call it in ajax (like if its inside a remote modal).
$(function(){ $(document).on('paste', '#textArea', function () { alert('paste !'); }); });
<html> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <!DOCTYPE html> <body> <textarea rows="4" cols="50" id="textArea"> </textarea> </body> </html>
Note :- The .on()
method attaches event handlers to the currently selected set of elements in the jQuery object
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.