I have a form in popup which loads by ajax request. For example input:
<input id="target" type="text" value="123">
And script:
test = $('#target').val();
console.log(test); //shows nothing
test2 = $('input#target').val();
console.log(test2); //shows 123
What can be the reason of such behaviour? Id of input is unique. Project is written on YII if it matters.
This kind of error normally indicates that you have duplicate
idattributes on your page, which is invalid. To test this use:If you see 0, or 1, it’s correct. If you see greater than 1 then you need to fix the duplicates.