craftyjs.github.com

HTML

Component allow for insertion of arbitrary HTML into an entity

Back to top

.replace

public this .replace(String html)

html
arbitrary html

This method will replace the content of this entity with the supplied html

Example

Create a link

Crafty.e("HTML")
   .attr({x:20, y:20, w:100, h:100})
   .replace("<a href='http://www.craftyjs.com'>Crafty.js</a>");
Back to top

.append

public this .append(String html)

html
arbitrary html

This method will add the supplied html in the end of the entity

Example

Create a link

Crafty.e("HTML")
   .attr({x:20, y:20, w:100, h:100})
   .append("<a href='http://www.craftyjs.com'>Crafty.js</a>");
Back to top

.prepend

public this .prepend(String html)

html
arbitrary html

This method will add the supplied html in the beginning of the entity

Example

Create a link

Crafty.e("HTML")
   .attr({x:20, y:20, w:100, h:100})
   .prepend("<a href='http://www.craftyjs.com'>Crafty.js</a>");