Here is the fiddle.
I am trying to make a comment system by getting the value of <textarea id='type'></textarea>
and prepend it as a div. The JS is currently:
$(document).ready(function(){
$('#b').click(function(){
var v = $('#type').val();
$('div').prepend(v);
});
});
<h1>Comments</h1>
<textarea id='type'></textarea>
<br />
<br />
<button id='b' onclick='comment()'>Submit</button>
But for some reason this code isn't showing the prepended var.
Edit
I have updated to have div but had already tried it. It didn't show up.
DEMO HERE
I added a div with
id='div1'
because you try to prepend toundefined
div
.Also styled your div with
color:white
so that you can see the text:And css :
jQuery code :