Sign in
Log inSign up

Dom Manipulation In Javascript Confusion

Default profile photo
Anonymous
·May 14, 2018
<input type="text" name="task" id="task">

Approach : 1 
const taskInput = document.querySelector('#task');
console.log(taskInput.value)

Approach 2
const taskInput = document.getElementById('#task');
console.log(taskInput.value)

Approach 3
const taskInput = document.querySelector('#task').value;
console.log(taskInput)

In the above code snippets which approach is more suitable ,I am following approach 1, it is working fine but unable to execute approach 2 and approach 3.Is approach 2 and approach 3 is invalid .