Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selecting the individuals from a group of jQuery elements

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 I seem to be missing something. I know I can see each one individually as if it was an array of objects.

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

But the above output is just the html; when I do that it's no longer a jQuery object :(

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

How do I continue to use jquery's methods on the individual without having to wrap each element again, or is this not possible for some strange, dark, inexplicable reason?

Didn't even know where to begin searching this one, and my jQuery journey has not lead me to the answer thus far. Thanks!

like image 693
jamil Avatar asked Apr 20 '13 01:04

jamil


1 Answers

Have a look at this page: jQuery Filtering

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

Should do the trick in this case

like image 131
tom-19 Avatar answered Oct 05 '22 08:10

tom-19