JSFiddle - React, Tailwind, and code Playground

by Timmy Willison

JavaScript

$.noConflict();

// Create an ifrmae.
var iframe = document.createElement( "iframe" );
document.body.appendChild( iframe );
var win = iframe.contentWindow;
var doc = win.document;
doc.write("<!doctype><html><body></body</html>");

// Inject jQuery
var script = doc.createElement("script");
script.src = "http://code.jquery.com/jquery-git.js";
doc.body.appendChild( script );


setTimeout(function() {
    $ = win.jQuery;
    
    // Test it.
    var elements = $.map( $(), function( elem, i ) {
        console.log('elem: %o, index: %d', elem, i);
        return elem;
    });
    
    // Should output []
    console.log( elements );
}, 2000);