html-demo-element advanced use

🏠 | Developer's documentation in Git repo | This page source

Programmatic change source, demo, text property or attribute from text or DOM subtree. Click on button to see this demo CSS, JS, or HTML code highlighted by PrismJs.

Programmatic content switch

demoElement.source = node
demoElement.source = text of
set source attribute from text of


<fieldset>
    <legend> demoElement.source = node </legend>
    <button onclick="setSourceByNode( 'css' )"> css   </button>
    <button onclick="setSourceByNode( 'js'  )"> js    </button>
    <button onclick="setSourceByNode( 'html')"> html  </button>
</fieldset>
<fieldset>
    <legend> demoElement.source = text of </legend>
    <button onclick="setSourceProp( 'css' )"> css   </button>
    <button onclick="setSourceProp( 'js'  )"> js    </button>
    <button onclick="setSourceProp( 'html')"> html  </button>
</fieldset>
<fieldset>
    <legend> set source attribute from text of </legend>
    <button onclick="setSourceAttribute( 'css' )"> css   </button>
    <button onclick="setSourceAttribute( 'js'  )"> js    </button>
    <button onclick="setSourceAttribute( 'html')"> html  </button>
</fieldset>

    
demoElement2.src = url
demoElement3.setAttribute('src', url)

Happy coding!