• Status: Solved
  • Priority: High
  • Security: Private
  • Views: 50
  • Last Modified:

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
0
Robb Hill
Asked:
Robb Hill
  • 2
2 Solutions
 
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 StanyonCommented:
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
 
Chris StanyonCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now