HTML 组件
允许将任意HTML插入到DOM实体中的组件。
将此组件添加到实体将自动添加DOM
组件。
方法
Back to top
.append()
public this .append(String html)
- html
任意的HTML
此方法将在实体的结尾添加所提供的HTML。
例子
创建一个链接
Crafty.e("HTML")
.attr({x:20, y:20, w:100, h:100})
.append("<a href='index.html'>Index</a>");
Back to top
.prepend()
public this .prepend(String html)
- html
任意的HTML
此方法将在实体的开始添加所提供的HTML。
例子
创建一个链接
Crafty.e("HTML")
.attr({x:20, y:20, w:100, h:100})
.prepend("<a href='index.html'>Index</a>");
Back to top
.replace()
public this .replace(String html)
- html
任意的HTML
此方法将用提供的HTML替换该实体的内容。
例子
创建一个链接
Crafty.e("HTML")
.attr({x:20, y:20, w:100, h:100})
.replace("<a href='index.html'>Index</a>");