2015-02-15 5 views
-1

У меня есть текстовое поле в html. Как получить значение текстового поля с использованием id.Как получить значение текстового поля с помощью функции javascript?

Ниже приведен пример кода отдельной строки.

function testing(){ 
    // tell the code for text box value id is "testing_id 
    console.log(value of textbox) 
} 
//calling function 
testing(); 
+1

'document.getElementById ('testing_id') value' – itzMEonTV

ответ

0

Использование document.getElementById

function testing(){ 
     console.log(document.getElementById('testing_id').value) 
    } 
    testing(); 
1

Вам нужно, чтобы получить вход-элемент, а затем проверить значение.

document.getElementById('...').value; // This will return the value of the textbox (... should equal the ID of the textbox 

Рабочий пример:. http://jsfiddle.net/thijs_s/cf31ob49/

Смежные вопросы