Jump to content

javascript assistance


Recommended Posts

This is supposed to insert the "item[value]" into the third input in a form but it's not. I'm clearly using "find("input", 3)" incorrectly, I was trying and hoping it would work like this, but it actually only finds the first element. And when I use it properly and remove the 3, it sets the value in all the inputs. How can I rewrite this to find "X" index position element in the "$(this).closest(".item-row")" and set what I need to?

$(this).closest(".item-row").find("input", 3).attr("value", item["value"]);


Link to comment
Share on other sites

I don't know jQuery, but you can use the vanilla getElementsByTagName function to get an array of elements by their tag and then happily use one of them by using the index :)

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...