I am trying to wrap HTML around an existing div, here is what I have attempted:
HTML:
<input type="text" data-placeholder="username" />
It should look like this when rendered:
<div class="placeholding-input">
<input type="text" data-placeholder="username" />
<label>Username</label>
</div>
This is my current progress:
$.each($('input[type="text"], input[type="password"], textarea'), function(){
var input = $(this);
var container = $('<div />').addclass('placeholding-input');
input.wrap(container);
var label = $('<label />').html(input.data('placeholder')).appendTo(container);
});
However, this code is not functioning as expected and I cannot figure out why.
Any assistance would be greatly appreciated. Thank you :)