Styling a list of checkboxes

Jeffrey de Boer April 13, 2017

A co-worker has created a custom field for a form, it only contains a whole bunch of checkboxes. (they simply created the field. Added the options. That's it)

Now by default it seems that you can give some styling with jQuery by giving each <div> element a style. But that means you can either sort the checkboxes and show them all in one line or display them like a list.

However they want to display these checkboxes as:

x       x
x       x
x       x
x       x

 

Any ideas on how to realise this? It seems difficult as somehow Jira creates these checkboxes all inside their own div element.

Thank you in advance.

2 answers

0 votes
Aleksa Svitlica February 5, 2020

You can add JavaScript to the description of the custom field. I believe you want something like this:

<script language="javascript">
AJS.$(document).ready(function(){
  Array.from(document.body.getElementsByClassName("checkbox")).forEach(function (cbox) {
    if (cbox.getAttribute('name')=='customfield_17126') {
      cbox.parentNode.style.cssFloat='right';
      cbox.parentNode.style.width='33%';
    }
  });
});
</script>

Just make sure to replace the number of the custom field ID to whatever your's is.

0 votes
Grigory Salnikov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 22, 2019

Hi @Jeffrey de Boer !

Have you managed to complete this task?

Suggest an answer

Log in or Sign up to answer