You can’t use val()
if the element has no value. It’s equivalent to document.getElementById("item").value
.
document.getElementById("item").innerHTML
would be equivalent to $('#item').html()
.
solved What is the difference in function between $(“#item”).val(); and document.getElementById(“item”).innerHTML;?