Champak Posted August 4, 2022 Posted August 4, 2022 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"]); Thanks.
TheDcoder Posted August 4, 2022 Posted August 4, 2022 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
genius257 Posted August 4, 2022 Posted August 4, 2022 (edited) Hi @Champak. try this: $(this).closest(".item-row").find("input").eq(3).attr("value", item["value"]); Edited August 4, 2022 by genius257 Champak 1 To show your appreciation My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now