conflunce html macro

i used a html macro to display a static table. A small piece of javascript is used to highlight the rows depending on table values. this works well on the preview screen. however, in the actual view, color highlight is no where to be found. does anybody know what is going on here?

below is my code in html macro:

<script type="text/javascript">

$('#report td.status').each(function(){
if ($(this).text() == 'failed')

{ $(this).css('background-color','red'); }

if ($(this).text() == 'passed')

{ $(this).css('background-color','green'); }




<table id="report">
<tr><td>1</td><td class="status">failed</td></tr>
<tr><td>2</td><td class="status">passed</td></tr>
<tr><td>3</td><td class="status">passed</td></tr>
<tr><td>4</td><td class="status">failed</td></tr>


1 answer

1 vote
Steven Behnke Community Champion Apr 01, 2016

This alternative works. Please note – 

  • Use AJS.toInit instead of document.ready
  • Use AJS.$ instead of $
  • Don't place <head><body>, or <html> tags in the macro


&lt;script type="text/javascript"&gt;
  $('#report td.status').each(function(){
    if ($(this).text() == 'failed') { 
    } else if (AJS.$(this).text() == 'passed') { 
&lt;table id="report"&gt;
    &lt;td class="status"&gt;failed&lt;/td&gt;
    &lt;td class="status"&gt;passed&lt;/td&gt;
    &lt;td class="status"&gt;passed&lt;/td&gt;
    &lt;td class="status"&gt;failed&lt;/td&gt;

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 12, 2019 in Confluence

Confluence Admin Certification now $150 for Community Members

More and more people are building their careers with Atlassian, and we want you to be at the front of this wave! Important Dates Start the Certification Prep Course by 2 April 2019 Take your e...

275 views 2 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you