/* CSS Document */
/* Swipe works with mouse as well but often causes text selection. */
#demo-page * {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
}
/* Arrow only buttons in the header. */
#demo-page .ui-header .ui-btn {
background: none;
border: none;
top: 9px;
}
#demo-page .ui-header .ui-btn-inner {
border: none;
}
/* Content styling. */
dl { font-family: "Times New Roman", Times, serif; padding: 1em; }
dt { font-size: 2em; font-weight: bold; }
dt span { font-size: .5em; color: #777; margin-left: .5em; }
dd { font-size: 1.25em; margin: 1em 0 0; padding-bottom: 1em; border-bottom: 1px solid #eee; }
.back-btn { float: right; margin: 0 2em 1em 0; }
#left-panel ul li .helperTextCss{
display:none;
}
#left-panel ul li .helperTextJs{
display:none;
}
#left-panel ul li .helperTextHtml{
display:none;
}
#resultContainer p{
font-size:1em;
}
JavaScript
$( document ).on( "pageinit", "#codeEditorView", function() {
$( document ).on( "swipeleft swiperight", "#codeEditorView", function( e ) {
// We check if there is no open panel on the page because otherwise
// a swipe to close the left panel would also open the right panel (and v.v.).
// We do this by checking the data that the framework stores on the page element (panel: open).
if ( $.mobile.activePage.jqmData( "panel" ) !== "open" ) {
if ( e.type === "swipeleft" ) {
$( "#right-panel" ).panel( "open" );
} else if ( e.type === "swiperight" ) {
$( "#left-panel" ).panel( "open" );
}
}
});
});
$("#runMyCode").click(function(){
$("#resultContainer").html($("#htmlTextArea").val());
var newScript = document.createElement('script');
newScript.id = "goback_script";
var newTextNode=document.createTextNode($("#jsTextArea").val());
newScript.type = 'text/javascript';
newScript.appendChild(newTextNode);
document.body.appendChild(newScript);
var newStyle = document.createElement('style');
var newTextNode2=document.createTextNode($("#cssTextArea").val());
newStyle.type = 'text/css';
newStyle.appendChild(newTextNode2);
document.body.appendChild(newStyle);
});
$('#goBack').click(function(){
var script = document.getElementById("goback_script");
script.parentElement.removeChild(script);
});
$('ul.left-nav li').click(function(){
var curCss=$('#cssTextArea').val() +'\n';
var curHtml=$('#htmlTextArea').val() +'\n';
var curJs=$('#jsTextArea').val() +'\n';
$('#cssTextArea').val(curCss+$(this).find('.helperTextCss').html());
$('#htmlTextArea').val(curHtml+$(this).find('.helperTextHtml').html());
$('#jsTextArea').val(curJs+$(this).find('.helperTextJs').html());
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.