0

I've read and tried numerous suggestions from Stack Overflow but none worked for me, forcing me to ask in person.

Currently I use this code to show and hide some content, the id tb1 is the div tag my content is wrapped in.

<input type="button" value="Information" onclick="javascript:sizeTbl('block');" />
<a href="javascript:sizeTbl('none');">(<i>Close</i>)</a>

The button is "Information" and I've added a clickable link that closes the content, because I can't get the button to register the javascript:sizeTbl('none');">(<i>Close</i>)

Can someone please tell me how to do this, I've tried simply adding the javascript:sizeTbl('none');">(<i>Close</i>) after the first onclick command like so:

onclick="javascript:sizeTbl('block');javascript:sizeTbl('none');"

but it doesn't work and I've also tried the below linked fixes but to no avail.

How to call multiple JavaScript functions in onclick event?

Two onClick actions one button

In case it's needed here is the main JS that defines tb1 etc.. I've also tried adding a new function directly in to that script (as I thought calling tb1 outside might cause an issue)

function sizeTbl(h) {
  var tbl = document.getElementById('tbl');
  tbl.style.display = h;
}
function sizeTb2(h) {
  var tb2 = document.getElementById('tb2');
  tb2.style.display = h;
}
function sizeTb3(h) {
  var tb3 = document.getElementById('tb3');
  tb3.style.display = h;
}
function sizeTb4(h) {
  var tb4 = document.getElementById('tb4');
  tb4.style.display = h;
}
$('#toggle-view').on('click', function() 
{
   var button = $(this);

   if ( button.hasClass('view-page')  ) 
   {
       ViewPage();
       button.removeClass('view-page');   
   } 
   else 
   {
        ViewMenu();
        button.addClass('view-page');
   }
});
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Samuel Nicholson
  • 3,587
  • 3
  • 20
  • 37

0 Answers0