var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.setValue($('textarea#input').val());
editor.setReadOnly(true);;
$('textarea#input').on('keyup', function (e) {
editor.setValue($(this).val());
});
$('a[data-language]').on('click', function (e) {
editor.getSession().setMode($(this).data('language'));
});
$('a[data-theme]').on('click', function (e) {
editor.setTheme($(this).data('theme'));
});
$('#bt-copy').on('click', function (e) {
if (document.body.createControlRange) {
console.log('okokalright!');
var htmlContent = document.getElementById('editor');
var controlRange;
var range = document.body.createTextRange();
range.moveToElementText(htmlContent);
//Uncomment the next line if you don't want the text in the div to be selected
range.select();
controlRange = document.body.createControlRange();
controlRange.addElement(htmlContent);
//This line will copy the formatted text to the clipboard
controlRange.execCommand('Copy');
alert('Your HTML has been copied\n\r\n\rGo to Word and press Ctrl+V');
}
});
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.