looping through arrays
looping through arrays
Hey Y'all, I've been trying this same thing in several different mini-jQuery plug-ins and it never quite does what I want it to.
I have a list of inputs
<div id="divID">
<input title="foo" type="text">
<input title="bar" type="text">
</div>
Then I'm trying to use jQuery to cycle through each input and ascribe ".attr("value") to each respective <input>
So far I've been using something along these lines:
var input = $('#divID input')
input.each(function(i) {
var title = input[i].attr("title");
input[i].attr("value", title);
}
If I remove the "[i]", it fills in every box with the title of the first <input>. If I leave it there, it fills in the first input, and then upon looping, says input[i].attr is not a function.
So, if I type console.log(input[1]), firebug returns the correct <input> tag, but as soon as I add the .attr(); function, it blows up.
What am I doing wrong? I feel like this one issue is holding me back from accomplishing several projects and I need to move on.
Thanks for your help!
Corey