JS Query selector

How can we pass 2 inputs in terms of form (like ,fname,lname ) using JS query selector?

You might be looking for the querySelectorAll() method…
It is similar to querySelector but returns a list of all objects which match the condition within (instead of just the first element)…

I don’t know what you are asking. You will have to provide some more information and clarification.

  • What do you mean by “pass 2 inputs in terms of form”?

  • What is fname and lname?

  • Are you talking about querySelector?

If you pass a string with multiple selectors to querySelector you will get the first element (first in the DOM) that matches one of the selectors. That is, you are able to query for two different elements with two different selectors, but you will only get the first match back.

<div id="main">main</div>
<div id="basic">basic</div>
const el = document.querySelector("#basic, #main");
console.log(el) // div#main

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.