yandex
loader

please wait

  • Priyanka Chadda Mar-07-2019 07:02:12 AM ( 2 months ago )
     Class='metric' title='Test gave a performance metric.' lastPassTag=''>1997.0
     Class='metric' title='Test gave a performance metric.' lastPassTag=''>1997.0
     Class='metric' title='Test gave a performance metric.' lastPassTag=''>1997.0
     Class='metric' title='Test gave a performance metric.' lastPassTag=''>1997.0
     class='detail-hide'> Class='result-name '>pmu: COMMITTED_PKT_BSB
     Class='metric' title='Test gave a performance metric.' lastPassTag=''>1655.0
     Class='metric' title='Test gave a performance metric.' lastPassTag=''>1836.0
     Class='metric' title='Test gave a performance metric.' lastPassTag=''>1655.0
     Class='metric' title='Test gave a performance metric.' lastPassTag=''>1836.0

    I have a HTML table like above I'm trying to do conditional formatting based on the formula applied on the numbers there I tried this:

    var tb = document.getElementByClass('metric')

    I could not get those values Any modifications or suggestions are appreciated Thank you
  • Imran Malik Mar-07-2019 07:05:36 AM ( 2 months ago )

    The only problem with your code is you are using wrong js context to search for class using js.

    document.getElementByClass('metric')


    as classes can be more then 1 so the context to select class is having elements instead of element like below

    document.getElementsByClass('metric')

    hope this will solve your query.

     

  • Deepak Parmar Mar-07-2019 07:09:19 AM ( 2 months ago )

    The method is wrong - you want to use document.getElementsByClassName:

    var tb = document.getElementByClass("metric");

    You could also use querySelectorAll to only get td elements with the class metric:

    var tb = document.querySelectorAll("td.metric");

     

     

     

  • Ayushi Jain Mar-07-2019 07:11:53 AM ( 2 months ago )

    There are two problems :

    1) You miss first  and last  and also must wrap your trs in table tag .

    2) Change :

    document.getElementByClass('metric') ;    

    To:

    document.getElementsByClassName('metric') ;

Please login

Similar Discussion

Recommended For You