Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div id="content">
<input id="testinput" value="testing123..." type="text" /></div>




                var domElement = function(selector) {
  this.selector = selector || null;
  this.element = null;
domElement.prototype.init = function() {
  switch (this.selector[0]) {
    case '<':
      var matches = this.selector.match(/<([\w-]*)>/);
      if (matches === null || matches === undefined) {
        throw 'Invalid Selector / Node';
        return false;
      var nodeName = matches[0].replace('<', '').replace('>', '');
      this.element = document.createElement(nodeName);
      this.element = document.querySelector(this.selector);
domElement.prototype.on = function(event, callback) {
  var evt = this.eventHandler.bindEvent(event, callback, this.element);
} = function(event) {
  var evt = this.eventHandler.unbindEvent(event, this.element);
domElement.prototype.val = function(newVal) {
  return (newVal !== undefined ? this.element.value = newVal : this.element.value);
domElement.prototype.append = function(html) {
  this.element.innerHTML = this.element.innerHTML + html;
domElement.prototype.prepend = function(html) {
  this.element.innerHTML = html + this.element.innerHTML;
domElement.prototype.html = function(html) {
  if (html === undefined) {
    return this.element.innerHTML;
  this.element.innerHTML = html;
domElement.prototype.eventHandler = {
  events: [],
  bindEvent: function(event, callback, targetElement) {
    this.unbindEvent(event, targetElement);
    targetElement.addEventListener(event, callback, false);{
      type: event,
      event: callback,
      target: targetElement
  findEvent: function(event) {
    return {
      return (evt.type === event);
    }, event)[0];
  unbindEvent: function(event, targetElement) {
    var foundEvent = this.findEvent(event);
    if (foundEvent !== undefined) {
      targetElement.removeEventListener(event, foundEvent.event, false);
    } = {
      return (evt.type !== event);
    }, event);
$ = function(selector) {
    var el = new domElement(selector);
    return el;

var a = $('<div>');
a.html('This div was created with the selector and this content was added with .html()');
$('#content').append('The value of #testinput is' + $('#testinput').val() + ' change the value to see thee bound event.');
$('#content').prepend('<p>Im prepended</p>');
$('#content').append('<p>Im appended</p>');
$('#testinput').on('change',function(){alert("The value of #testinput changed");})