Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to add expand/collapse icon in html?

hema36
Kilo Explorer

Hi,

 

In Knowledge Management, while creating an article when I change the article type corresponding template will appear inside the text field. In every template there will be a heading and description below that. For each heading of the article, I need to add expand/collapse icon at the right end so that I can expand/collapse the description below the title. Can anyone help me in doing this in HTML ?

 

Regards,

Hema P

24 REPLIES 24

Hi Norma,



We are facing same issue. Kindly let me know is there any way to fix this issue. it is working on knowledge article creation page. But it is not working on article page. You can find the snap shots. knw.article1.PNGknw.article2.PNG


Hi Jyothikala,


When you click back on the "Please click here" to close it, does it not close? It has been working for me in Firefox and Chrome using the code in the HTML editor, but it is a very manual process. Making changes in the text editor doesn't always work.



On the article creation page, it doesn't collapse at all?


N


Manjul Katare
ServiceNow Employee
ServiceNow Employee

Hi All,



This can be achieved with below UI Script & HTML snippet. The only thing is you'll have to paste below HTML snippet in TinyMCE Editor using HTML Mode.



HTML Snippet:



<fieldset class="expandCollapseBlock"><legend style="font-size: 12px;"> [+/-]   First Block Heading Here</legend>


<div class="dataContent">


<ul>


<li>Item One</li>


<li>Item Two</li>


<li>Item Three</li>


</ul>


</div>


</fieldset>


<p> </p>


<fieldset class="expandCollapseBlock"><legend style="font-size: 12px;"> [+/-]   Second Block Heading Here</legend>


<div class="dataContent">


<ul>


<li>Item One</li>


<li>Item Two</li>


<li>Item Three</li>


</ul>


</div>


</fieldset>



UI Script:


$j(document).ready(function(){


  var myEC = $j('fieldset.expandCollapseBlock');


  if (myEC.length){


  console.log('expandCollapseBlock was here!!!!!!!');


  $j('fieldset.expandCollapseBlock').click(function(){


  $j(this).find('div.dataContent').toggle();


  });


  }


});



Your KB Article in TinyMCE would be look something like this:


Screen Shot 2015-11-21 at 10.48.52 PM.JPG



And your end result would be :


Screen Shot 2015-11-21 at 10.54.37 PM.JPG



Now when you click anywhere on content, it would expand and collapse the content.




Hope this help!


-Manjul


Thank you, Manjul! I appreciate the help!



Norma



Best wishes,



Norma Ohlenbusch



On Sun, Nov 22, 2015 at 12:57 AM, manjul.katare <


Manjul Katare
ServiceNow Employee
ServiceNow Employee

You are more than welcome Norma, I'm glad I was able to help.


If you are satisfied with an answer please mark this thread as Helpful.



-Manjul