onclick機能を切り替える画像を取得しました。呼び出される関数は、オブジェクトのメソッドです。私の問題:オブジェクトの名前がわからないので、どうすればよいですか?
初期HTMLコード:
<img id="someID" [...] onClick="someObject.aFunction();" />
結果が欲しかった:
<img id="someID" [...] onClick="someObject.otherFunction();" />
私の現在のJavascript(回避策):
someClass.prototype.aFunction() = function() {
button = document.getElementByID('someID');
button.setAttribute("onclick", button.getAttribute('onclick').split('.')[0]+'.otherFunction()');
}
あまり良くありませんが、今のところは機能します。より良い解決策はありますか?