Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

168
Vistas
Why VS Code autocomplete doesn't suggest .value attribute when working with Java Script file?

HTML:

  <body>
    <h1>Grocery List</h1>
    <form action="/nowhere">
      <label for="item">Enter A Product</label>
      <input type="text" id="product" name="product" />
      <label for="item">Enter A Quantity</label>
      <input type="number" id="qty" name="qty" />
      <button>Submit</button>
    </form>

    <ul id="list"></ul>
  </body>

Java Script:

const frm = document.querySelector("form");
const prdct = document.querySelector("#product");
const qty = document.querySelector("#qty");
const mylst = document.querySelector("#list");

frm.addEventListener("submit", (e) => {
  e.preventDefault();
  const myele = document.createElement("li");
  myele.textContent = qty.value;
  myele.textContent += ` ${prdct.value}`;
  mylst.appendChild(myele);
  qty.value = "";
  prdct.value = "";
});

As can be seen, VS code isn't suggesting '.value' attribute with other suggestions. What can be the reason?

VS code not suggesting .value attribute

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

Document.querySelector() returns a Element, so the editor cannot know that it has a value.

If you would create the element by javascript, then the editor DOES know...

let input = document.createElement("input")
let test = input.value // now you can get autocomplete

Another way is to use typescript :

let input:HTMLInputElement = document.querySelector("myinput")!
let test = input.value // now you can get autocomplete
about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda