Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<my-element content="Custom Element">
  Hello
</my-element>
</body>
</html>
 
class MyElement extends HTMLElement {
  get content() {
    return this.getAttribute('content');
  }
  set content(val) {
    this.setAttribute('content', val);
  }
}
window.customElements.define('my-element', MyElement);
function customTag(tagName, fn){
  Array
    .from(document.getElementsByTagName(tagName))
    .forEach(fn);
}
 
function myElementHandler(element) {
  element.textContent = element.content;
}
customTag('my-element', myElementHandler);
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
ruanyfpro
0viewers