Jquery Row + add attribute on each id using row.find

I have a row object that I need to use the row.find method
and essentially go through every control and add an attribute on the control...or maybe even change the ID....

I am thinking attribute would be easier.


I guesss I would need to to through each tr/td in this table and find the id..then make the change.

This row object only has one tr....and only 6 td....each td only has one control  
label,  selectlist,selectlist, decimal input, button, button
LVL 11
Robb HillSenior .Net DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Robb HillSenior .Net DeveloperAuthor Commented:
I did this...and it seems to find my one input and my two selects....
I still need it to find label..and also add the attribute on each one it finds.


     row.find('input, select, textarea').each(function()
{

    alert(this.tagName);
});

Open in new window

0
Chris StanyonWebDevCommented:
If you just want to add an attribute to each matching element, then do it inside your function:

row.find('input, select, textarea').each(function()
{
    this.attr('someAttribute', 'someValue');
});

Open in new window

1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Chris StanyonWebDevCommented:
Sorry - that should be:

$(this).attr(...);
1
Miguel OzSoftware EngineerCommented:
Just complementing previous answers add the label to query.
Notice that for id is better to use prop
row.find('input, label, select, textarea').each(function()
{
    $(this).prop('id', 'newId');
     $(this).attr('someAttribute', 'someAttributeValue');
});

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.