components icon indicating copy to clipboard operation
components copied to clipboard

unable to use JS code inside index.js from page

Open rebeccasharon opened this issue 4 years ago • 1 comments

For example, In index page I have included all the JS and CSS files, pages will be in separate HTML files. I have a page named Home.html, and I have a button. In JS I have $('.plus-btn').on('click', function(e) { alert("Hi"); });

The alert is not being fired. If I mention a function to call from button onClick(), this is being called.

I tested by placing the JS code inside .ready() and document.addEventListener("deviceready", function(){ });

Still not working.

Is there any code I'm missing. Help would be appreciated.

rebeccasharon avatar Apr 20 '20 18:04 rebeccasharon

This is because web itself does not allow js to execute inside the same page. Try have an external js file and linking it to the html document.

Jack-Drake avatar Dec 14 '20 07:12 Jack-Drake