0
How i can in JavaScript?
how to input the value of variable in JS?
6 Antworten
+ 3
You mean probably something like window.prompt() function:
https://developper.mozilla.org/en-US/docs/Web/API/Window/prompt
+ 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 ;) )
+ 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!
+ 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
+ 1
i oh see.. thanks bro
0
i mean like.. scanf on C, or cin on C++