[Solved] Uncaught type error is not a function [closed]


You need to include the javascript above the HTML, or add your JavaScript to some kind of page load.

Example:

document.addEventListener("DOMContentLoaded", function(){
  // ADD CODE
});

Your JavaScript should be working when included correctly as seen in here:

function showdivs() {
    var yourUl = document.getElementById("tryok");
    yourUl.style.display = yourUl.style.display === 'none' ? '' : 'none';
    var yourU2 = document.getElementById("tryok2");
    yourU2.style.display = yourU2.style.display === 'none' ? '' : 'none';
}
<p> Deseja inserir esta amostra numa experiencia? <input type="checkbox" id="showdivs" onclick="showdivs()"</input></p>
<div id="tryok"><p>UI1</p></div>
<div id="tryok2"><p>UI2</p></div>

3

solved Uncaught type error is not a function [closed]