I am trying to create a function that allows the author of a document to execute code that they have entered. The page looks like this:
As you can see the author can enter code snippets, however, I would like them to be able to check what they have entered is correct. I have an idea similar to what is used on stack overflow. I want to reader to be able to click the "Play Code Snippet" Button and the result to be shown. At the moment the result is hardcoded and once the user pressed the show button the webpage looks like this:
This is the jQuery for that:
<script>
(function () {
$(document).ready(function(){
$('#showCode').click(function(){
$(".resultSection").addClass("show");
});
$('#hideResult').click(function(){
$(".resultSection").removeClass("show");
});
});
})();
</script>
How do I take the code/input from the code section (.codeSection) and execute it using javascript to then output the correct response?
I am also using Laravel, are there any helpers that it could provide?
Any help would be great! Thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire