Assigning a value to a form using .val ()

After going through some third-party code, I realized that they assign a value to the form using .val () and then represent the form.

$('#form-ID').val("Some Value");

This is a valid jquery statement, and if you do

$('#form-ID').val()

you get "Some Value"on the console but no HTML change is observed to reflect "Some value". Therefore, if there is no change to HTML, then:

  • Why assign a value to a form?

  • If required, how does the PHP code read this value?

+3
source share
1 answer

, HTMLFormElement , value, val , , expando. :

var d = $("<div>");
d.val("foo");
console.log(d.val());    // "foo"
console.log(d[0].value); // "foo"

value expando ( ), , , . , , , . ( - val - .)

+7

All Articles