Thanks @nnnnnn sir.
The code binds the event keyupto everyone inputsalready owned by the DOM and immediately fires it for these inputs.
Now
$("input").keyup(function () {
var value = $(this).val();
$("p").text(value);
});
the above code binds the event keyupto input, and the latter .keyup()makes the initial trigger for keyup.
You can also rewrite the code above:
$("input").keyup(function () {
var value = $(this).val();
$("p").text(value);
})
$('input').keyup();
Does it create an infinite loop?
NO . It only starts once when the page loads. See here
source
share