I've been trying to get this idea I had together for a simple project i'm working on.
The result I would like is to have a button that when clicked adds the barebones tags of a HTML5 doc. From there, I'd like to be able to add other HTML tags to it as well such as, lists, paragraphs, headers,a page title etc. and have them be in their proper place so if I add a <p>
tag it'll be added in the body however, when I'm adding the <title>
it will be under the head.
The problem I'm running into is that I've figured out how to get the "tags" into the textarea using it's .val()
selector, but it's technically text NOT actual HTML so, I don't know how I could add/remove other elements without somehow switching the text in the textarea to actual HTML and try append or prepend every time a button is clicked from there.
here's what I have so far for the jQuery...
$(document).ready(function () {
$("button#setup").click(function () {
var text_area = $("#code_window")
$(text_area).val("<!DOCTYPE html>" + "\n" + "<html>" + "\n" + "<head>" + "\n\t\n" + "</head>" + "\n" + "<body>" + "\n\t\n" + "</body>" + "\n" + "</html>");
});
});
and here's everything together..
Anything you could contribute would be appreciated.
Thanks!