获取自动填充的输入的值-jQuery [英] Getting the value of autofilled inputs - Jquery

查看:146
本文介绍了获取自动填充的输入的值-jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,当某些浏览器自动填写表单登录时,它会导致我的交互式占位符出现问题.占位符是一个<span>元素,其中包含一些文本,当聚焦时,该占位符将移至输入本身上方.当浏览器插入记住"的数据时,我如何能够检测到它的存在及其价值?

So, as some browsers auto-fill sign in forms, it causes an issue with my interactive placeholders. The placeholder is a <span> element with some text in, which moves above the input itself when focussed. Upon the browser inserting the data it has 'remembered', how would I be able to detect its presence, and it's value?

请注意,这是我希望获取的输入的自动完成值.

Please note, that it is the auto-completed value of the input which I wish to grab.

推荐答案

使用以下代码,我成功实现了希望的结果:

Using the following code, I have managed to achieve the result I wished for:

setTimeout(function() {
    console.log($('#input').val());
});

使用超时允许浏览器在代码向其请求数据之前先加载自身.

Using a timeout allowed the browser to load itself prior to the code requesting data from it.

这篇关于获取自动填充的输入的值-jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆