Because $().value
is undefined
(not a function).
The value
property belongs to the HTMLInputElement
DOM interface, jQuery objects don’t have any property or method by that name.
jQuery objects provide the .val()
method to set elements’ value
property:
$('.usp-title input').eq(0).val(name);
You may also get and set DOM element properties directly by retrieving a DOM element reference from the jQuery object through the .get
method:
$('.usp-title input').get(0).value = name;
$('.usp-title input')[0].value = name; //shorthand form
solved What is wrong with my jQuery code? Gives error that it’s not a function [closed]