I'd like to change the tag while maintaining the attributes within said tag then have one of the values of the attribute be used within the textarea.
Here's a sample code:
<tbody>
<tr>
<td someClass>
<input attrOne="one" attrTwo="two" value=""></input>
</td>
</tr>
</tbody>
Here's my code that replaces the tag and keeps the attributes:
<script>
jQuery('.someClass input').replaceWith(function () {
return this.outerHTML.replace("<input", "<textarea").replace("</input", "</textarea")
});
</script>
It's a form that allows users to type in anything and the 'value' attribute becomes what they type in. When I look at the source code, the value shows up fine. But the value of 'value' attribute is not being input into the textarea.
Here's what I tried but gives me blank:
<script>
jQuery('.someClass').children('textarea').text(jQuery('.someClass textarea').attr("value"));
</script>
How would I go about grabbing the value of 'value' attribute and putting it within the textarea?