Skip to content Skip to sidebar Skip to footer

Getting The Value Of Autofilled Inputs - Jquery

So, as some browsers auto-fill sign in forms, it causes an issue with my interactive placeholders. The placeholder is a element with some text in, which moves above th

Solution 1:

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.

Solution 2:

Give the span an ID and run the text() method on it. Without any parameters it works as a getter.

var yourtext = $('#somespan').text();

If it was an actual textfield instead of a span, you would get the contents with the .val() method.

var yourtext = $( "#foo" ).val();

Post a Comment for "Getting The Value Of Autofilled Inputs - Jquery"