How i can in JavaScript? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

How i can in JavaScript?

how to input the value of variable in JS?

25th Dec 2016, 12:10 AM
Abas
Abas - avatar
6 ответов
+ 3
You mean probably something like window.prompt() function: https://developper.mozilla.org/en-US/docs/Web/API/Window/prompt
25th Dec 2016, 12:15 AM
visph
visph - avatar
+ 2
JS run in browsers, so there's not strict equivalent ^^ However, window.prompt() is quiet same functionnality, but in graphic ui... else you can use <input type='text"> html tag ( or one of the new type for input in html5 ), and access to its value with JS ( you can also "watch" events like others html element ;) )
25th Dec 2016, 12:29 AM
visph
visph - avatar
+ 2
If you want use other element than <input> to manage a user entry with the innerHTML element property, you must set the contenteditable css attribute to "true"... For printing ( manage output ), you just have to assign a string to the innerHTML property: it accept ( and interprete ) html, so if you want printing "as his" you need to encode the string for escaping characteres like "<" and ">" ( "&" and quotes are recommended too )... else, it's a powefull way to generate html on the fly!
25th Dec 2016, 12:42 AM
visph
visph - avatar
+ 1
JS has no input output methods. It can only read from the environment and write to an environment. element.innerHTML is one of the methods to read write
25th Dec 2016, 12:32 AM
Rishi Anand
Rishi Anand - avatar
+ 1
i oh see.. thanks bro
25th Dec 2016, 12:33 AM
Abas
Abas - avatar
0
i mean like.. scanf on C, or cin on C++
25th Dec 2016, 12:21 AM
Abas
Abas - avatar