Selecting faces from a jQuery element group

If I use jquery to select all my text inputs:

var inputs = $('#form input[type="text"]');

They are wrapped in jQuery. I can do whatever I want with them.

inputs.css('height', '1000px');
//muhahaha!

As a group, they abide. But it seems to me that something is missing. I know that I can see each separately, as if it were an array of objects.

console.log(inputs[0]);
// <input type="text" />

But the above output is just html; when I do this, this is no longer a jQuery object :(

inputs[0].css('font-size', '100px');
// Uncaught TypeError: Object #<HTMLInputElement> has no method 'css'

How can I continue to use jquery methods for an individual user without the need to re-wrap each element, or is this impossible for some strange, dark, inexplicable reason?

Didn't even know where to start looking for this, and my jQuery journey has not led me to answer so far. Thank!

+5
source share
3 answers

: jQuery

inputs.eq(0).css('font-size', '100px');

+5

. .eq() JQuery-API

Dom- Node -Collection JQuery Array-Index RAW-, , jQuery-Wrapped- . . .

+1

The only way to avoid repackaging each item ( $(inputs[0]).css('font-size', '100px'))

will use pure javascript. Example:inputs[0].style.fontSize = "100px";

0
source

All Articles