[英]jQuery: autofill input values with mouse click not keyboard
I'm using this solution https://stackoverflow.com/a/4932770/3108268 我正在使用此解决方案https://stackoverflow.com/a/4932770/3108268
$("#EmailAddress").keyup(function(){
$("#Username").val(this.value);
});
And it works fine when typing input values with a keyboard, it auto fills the selected field. 使用键盘输入输入值时,它可以很好地工作,它会自动填充所选字段。
But it doesn't work when filling a field with a mouse click from calendar popup javascript plugin. 但是,当从日历弹出式JavaScript插件中单击鼠标来填充字段时,它不起作用。 The popup plugin gives the input classes hasDatepicker date-popup-init
. 弹出插件给输入类hasDatepicker date-popup-init
。
This is all inside Drupal 7, but I don't think it's relevant. 这些都在Drupal 7内部,但我认为这无关紧要。
Here's an example, as you can see the time field is plain text and autofills below, because it is being filled with a keyboard while filling the date field with mouse click from calendar popup does not fill the field below it (but does if you force-type with keyboard). 这是一个示例,如您所见,时间字段是纯文本,并在下面自动填充,因为它是用键盘填充的,而用鼠标从日历弹出窗口中填充日期字段则不会填充其下方的字段(但是如果您强制-用键盘输入)。
You could use change
event; 您可以使用change
事件;
$( "#EmailAddress" ).change(function() {
$("#Username").val(this.value);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.