Change colspan color in HTML with Javascript -


i have problem. color 1 word, , not row's words. e.g.: great, if passed became green, failed became red, , not testable became orange without coloring last result text. how can refer words, , coloring without last result text?

here javascript code:

javascript: (function()  {      var = window.frames['mainframe'].frames['workframe'].document.getelementsbytagname("b");       (var i=0, max=all.length; < max; i++)           {              if(all[i].innerhtml == "failed" )                 {                      all[i].parentnode.parentnode.style.textcolor = "white";                      all[i].parentnode.parentnode.style.color = "red";                  }                if(all[i].innerhtml == "passed")                 {                      all[i].parentnode.parentnode.style.backgroundcolor = "white";                      all[i].parentnode.parentnode.style.color = "green";                  }                if(all[i].innerhtml == "blocked")                 {                      all[i].innerhtml = "not testable";                      all[i].parentnode.parentnode.style.backgroundcolor = "white";                      all[i].parentnode.parentnode.style.color = "orange";                  }           }       } )(); 

and here html code:

<tr>   <td width="20%" valign="top">     <span class="label">last result:</span>   </td>   <td colspan="2">     <b>passed</b>   </td> </tr> 

you should use if , else if make script working

or take script below, working

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script>     $(document).ready(function () {         $('b').each(function (index, value) {             var status = $(this).html();             if (status === "passed")                 $(this).css("color", "green");             else if (status === "failed")                 $(this).css("color", "red");             else if (status === "blocked") {                 $(this).css("color", "orange");                 $(this).html("not testable");             }         });     }); </script> 

`

and here html

<table>     <tr>        <td width="20%" valign="top">           <span class="label">last result:</span>        </td>        <td colspan="2">            <b>passed</b>         </td>     </tr>     <tr>         <td width="20%" valign="top">             <span class="label">last result:</span>         </td>         <td colspan="2">             <b>failed</b>         </td>     </tr>     <tr>         <td width="20%" valign="top">             <span class="label">last result:</span>         </td>         <td colspan="2">             <b>blocked</b>         </td>     </tr> </table> 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

Maven Javadoc 'Cannot find default setter' and fails -