+ 3
JavaScript output problem
Hello can you please fix my code . Something is wrong with if else or anything else. I have written if(a=="java") $("body").html("java") else $("body").html("C++") Whenever I input Java it shows C++ ? Why Please help me. https://code.sololearn.com/W7Xsd0tuD16a/?ref=app
2 Answers
+ 1
There are a few problems with the HTML and JS.
- Give the id âchooserâ to the input element of type text rather than the div
- Your selector is wrong to get the value out of the text field you need a hash/pound (#) sign in front of it - â#chooserâ
- It is .val() not .valueOf() to get the text from the text box
Changes:
https://code.sololearn.com/W29s3e607h6e/?ref=app
+ 2
//Methods are same as TurtleShell showed
https://code.sololearn.com/WLMABlhL0AxR/?ref=app