Topic on Project:Support desk

[RESOLVED] Expand collapsed elements by anchor

2
108.174.24.202 (talkcontribs)

I have a 10 divs with the mw-collapsible mw-collapsed class, they are all working fine but I would like to expand a specific div depending on the anchor in the link.

Is this possible?

108.174.24.202 (talkcontribs)

I found the solution by adding a function to Common.js:

$( document ).ready(function() {
   $(expandByAnchor()).removeClass('mw-collapsed');  
});
 
var expandByAnchor = function() {
   if(window.location.hash) 
   {
      var hash = window.location.hash; //Leaves # character
      return (hash);      
   } 
   else
   {
      return ('');
   }
};
Reply to "[RESOLVED] Expand collapsed elements by anchor"