How can I include a html select in Confluence with jquery?

Szabó Dániel June 22, 2020

I would like to include a html select into a confluence page, and I would like to have different background color for each option. I do have the background color for each option, but when I select the option it does not keep the background color. Could someone please help?

Here is the html:

<script type="text/javascript">

AJS.$("#select").change(function(){

var color = $("option:selected", this).attr("class");

$("#select").attr("class", color); });

</script>

<select id="select" class="">

<option class="yellow">Waiting for test</option>

<option class="green">Passed</option>

<option class="red">Failed</option>

</select>

Here is the css:

 

.green {  

    background-color: green;  

}  

.yellow {  

    background-color: yellow;  

}  

.red {  

    background-color: red;  

}  

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events