html5 - Cannot call JavaScript object method from 'onclick' event handler -


i trying call following function onclick event handler of html element, it's not being called:

storesync.close = function () {     alert("test"); } 

here's html part:

 <div onclick="storesync.close()"></div> 

any appreciated. thanks!

you must declare object storesync use inside domelement.

there 2 standard ways that:

var storesync = {     close: function() {         alert("test");     } } 

or:

var storesync = {}; storesync.close = function() {     alert("test"); } 

var storesync = {      close: function() {          alert("test");      }  }
<div onclick="javascript: storesync.close();">click me!</div>


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -