15 lines
434 B
JavaScript
15 lines
434 B
JavaScript
$(document).ready(function() {
|
|
$(".example .try_it button").click(function() {
|
|
let textarea = $(this).parent().children('textarea').first();
|
|
if (!textarea) {
|
|
console.error('Textarea associated to this button not found.')
|
|
}
|
|
|
|
// Save example to local storage
|
|
localStorage.setItem('saved_code', textarea.val());
|
|
localStorage.setItem('saved_language', 1);
|
|
|
|
// Redirect to home page
|
|
document.location.href=".";
|
|
});
|
|
}); |