我有一个按钮,我希望能够单击该按钮并将图像更改为其他内容,听起来很简单。
<buttonLockup toggle="true">
<badge src="resource://button-rate-off" class="whiteButton" />
<title>Add to Favourites</title>
</buttonLockup>
应改为:
<buttonLockup toggle="true">
<badge src="resource://button-rate-on" class="redButton" />
<title>Remove from Favourites</title>
</buttonLockup>
在我的 Presenter.js 中,我有一个加载函数,可以检测到我选择了该项目:
load: function(event) {
console.log(event);
var self = this;
var ele = event.target;
var toggle = ele.getAttribute("toggle");
if (toggle)
{
console.log(ele);
var badge = ele.getElementsByTagName("badge").item(0);
console.log(badge);
badge.src = "resource://button-rated"; // Doesn't change
}
},
关于如何改变它的任何想法?