Answer the question
In order to leave comments, you need to log in
Why does the console output only the first word from the value of the button element?
There is this form:
<form action="/" method="POST">
<input type="text" name="newItem" placeholder="new task" autocomplete="off">
<button type="submit" name="list" value=<%= listTitle %> >+</button>
</form>
listTitle
is passed as followsres.render("list", {listTitle: "Work List Title", newListItem: workItems})
list
to the console node, I only get the first word before the space - Work . But if I set list
not a variable, but the string "Work List Title" , then the entire line is displayed in the console. Explain, please, why so?
Answer the question
In order to leave comments, you need to log in
because
<button type="submit" name="list" value=<%= listTitle %> >+</button>
at the output gives<button type="submit" name="list" value=Work List Title >+</button>
those. button
with attributes .
You can do like thisvalue="Work" List="" Title=""
<button type="submit" name="list" value="<%= listTitle %>" >+</button>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question