Highlighting rows in jquery using bootsrap

Hey guys... I have a table that has this scenario:

<tr class="warning c_APLM">
    <td style="vertical-align: middle;">5</td>
    <td style="vertical-align: middle;"><a href="#" onclick="onHold('APLM','20',this); return false;" class="t_APLM" data-hold="False" data-class="warning"><i class="icon-folder-open-alt"></i></a></td>
</tr>
<tr class=" c_APLM">
    <td style="vertical-align: middle;">6</td>
    <td style="vertical-align: middle;"><a href="#" onclick="onHold('APLM','20',this); return false;" class="t_APLM" data-hold="False" data-class=""><i class="icon-folder-open-alt"></i></a></td>
</tr>

Open in new window

These two rows share the same <tr> class (c_APLM). What they don't share is the highlight class (warning). For example: notice on the first <tr> it has a highlight of warning, while the other has no highlight. What i'm trying to do is if their current <a> data-hold=false, then since they are both part of the same tr class, make them both change their highlight to the info color which means the record is being held. Where i'm stuck is, let's say i wanna undo my hold and bring them back to the highlight they started with. I can't seem to pull this off. You'll notice that on the <a> i have a data-class. This is always going to be the original highlight. I can't seem to get it going. Here's what i got so far, and as always, all help is GREATLY appreciated!

function onHold(c,id,e){

  var h = $(e);

  // if it's onHold then make active (open folder)
  if(h.attr('data-hold')=='True'){

    // remove whatever the previous highlight was and revert back to original highlight
    $('.c_'+c).removeClass('warning danger info').addClass($('.c_'+c+' a').attr('data-class'));

    h.attr('data-hold','False');

  } else {
    //put on hold (close folder)

    // remove whatever the highlight is and make it the "info" highlight
    $('.c_'+c).removeClass('warning danger info').addClass('info');

    h.attr('data-hold','True');

  }
}

Open in new window

LVL 3
engineroomAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
MrunalConnect With a Mentor Commented:
Hi
Check this out.
I am not clear with your exact requirement but this will help you.

http://jsfiddle.net/954LmbzL/1/

Please share your comments on this.
0
All Courses

From novice to tech pro — start learning today.