Example 1 — Official Demo: input[name^="news"]
Find inputs whose name starts with news, then set a new value.
$("input[name^='news']").val("news here!");
var names = $("input[name^='news']").map(function () {
return this.name;
}).get().join(", ");
console.log(names);
// newsletter, newsboy How It Works
- Limit to inputs. The
inputtag keeps the search on form controls. - Apply ^=. Only names that begin with
newsmatch. - Skip mid-word hits. A name like
my_newswould fail — prefix must be first.

