Code is at: http://jsfiddle.net/m9yen/
Issue:
- I have multiple LI’s listing FOOD ITEMS
- Each li contains a link (add) and in that href is a rel which holds that specific FOODID
- I now need to have an input box for QUANITY
- I also need to a select with dropdowns for SERVING TYPE (i.e. grams, et which I’ll populate)
- End issue is when the add is clicked, I need to get the rel for the href, the value of the input and the selected option for that specific LI ONLY and sent it to request.php via ajax.
Now I did have it working specifically with the rel only sine it was a if href is clicked get attr(‘rel’) and submit it via ajax to request.php — BUT since this requires other values of items outside the href but only within that specific LI, I’m lost and have tried using .find() with no luck what so ever.
NOTE: There will be more than one, possible 50-100 listings (each LI)
Since
inputandselectelements are its siblings you have to usesiblingsmethod to find them. Since the name of the elements are same as what you are matching use=instead of=^=and just use"rel"to get the attribute value from anchor instead of"a#rel".Demo