问题
I am using ('keyup paste', function() to fill a <div>, but I do not know what to do when someone uses autofill. Also I am using cookies for a previous visitors that filled out the form. So I would like to also know how to fill the div when someone uses autofill or has the field populated with a cookie.
Here is my current script:
$(function () {
$('#Website').on('keyup paste', function() {
var self = this;
setTimeout(function() {
var str = $(self).val();
$("#viewer").text(str.replace(/^http\:\/\//, ''));
}, 0)
})
});
回答1:
Try this:
$(function () {
$('#Website').on('keyup blur paste', function() {
var self = this;
setTimeout(function() {
var str = $(self).val();
$("#viewer").text(str.replace(/^http\:\/\//, ''));
}, 0)
})
});
来源:https://stackoverflow.com/questions/20369344/jquery-copying-an-input-to-a-div-with-keyup-paste-having-an-issue-with-autofi