Notice: The Monaca & Onsen UI Community Forum is shutting down.

For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.

Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.

Not able to execute Jquery hide and show

  • I am trying to hide and show p tag on two different button click but I am not able to get it .

    Error I am getting :

      "Uncaught TypeError: Cannot call method 'addEventListener' of null", 
       source:file:///android_asset/www/js/index.js (48)


    <p id="hidep">If you click on the "Hide" button, I will disappear.</p>
    <button id="hide" onclick="hideButton()">Hide</button>
    <button id="show" onclick="hideButton()">Show</button>


     function onLoad() {
    document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {
    document.getElementById('demo').addEventListener("click", printMsg, false);
    document.getElementById('show').addEventListener("click", hideButton, false);
    document.getElementById('hide').addEventListener("click", hideButton, false);
    document.addEventListener("pause", onPause, false);
    document.addEventListener("resume", onResume, false);
    document.addEventListener("menubutton", onMenuKeyDown, false);
    function hideButton(){

  • Onsen UI

    @Ashish Well, the error says Cannot call method 'addEventListener' of null. That means that either you misspelled the variable/object name or there is a timing issue and it is not ready yet. You need to find which line of code calling addEventListener throws the error.

  • Ya I got the result actually the listener for id demo was not doing anything and when i removed that it started working Thanks again