+ 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

16th Mar 2019, 4:34 PM
Rajat Tiwari
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
16th Mar 2019, 5:02 PM
TurtleShell
TurtleShell - avatar
16th Mar 2019, 7:38 PM
Sudarshan Rai
Sudarshan Rai - avatar