Reputation: 25
I know I can target an input element with a specific name, for example
$("textarea[name=form_textarea]").val();
However I can't seem to find any examples of how I could go about changing the name itself, is this possible?
Upvotes: 0
Views: 34
Reputation: 13812
$("textarea[name=form_textarea]").attr("name", "new_name");
$("textarea").val("Name is: " + $("textarea").attr("name"));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<textarea name="form_textarea"></textarea>
Upvotes: 2