尝试将字符串转换为HTMLDivElement对象。我知道如何创建字符串,但不确定如何创建HTMLDivElement。
例如,如果我想将
同时了解HTMLDivElementObject的含义也很重要。
编辑:
我还知道有通用属性,例如id(字符串),style(对象),title(字符串)和className(字符串)。
以下是我的函数和方法。正如您所看到的,我尝试创建toElement方法。我需要的是该方法返回表示卡片的HTMLDivElement对象。需要返回的示例与上述相同
例如,如果我想将
<div id="cardId" class="card c9"></div>
转换为HTMLDivElement对象。同时了解HTMLDivElementObject的含义也很重要。
编辑:
我还知道有通用属性,例如id(字符串),style(对象),title(字符串)和className(字符串)。
以下是我的函数和方法。正如您所看到的,我尝试创建toElement方法。我需要的是该方法返回表示卡片的HTMLDivElement对象。需要返回的示例与上述相同
<div id="cardId" class="card c9"></div>
。var cardProto = {
// creates the HTML string representing this element
"toString": function (){
var s = this.card.getSuit(), r = this.card.getRank();
var t = "<div class=\"card ";
t += s !== undefined ? s + r : "down";
t += "\" id=\""+ this.id + "\"></div>\n";
return t;
},
"toElement": function () {
}
};