Error get name value copy from textarea
<script>
$(document).ready(function(){
$('.next').click(function(){
$('input#productname').val($('input#_productname').val());
$('textarea#description').val($('textarea#_description').val());
});
});
</script>
<input type="text" name="_productname" id="_productname" value="demo"/>
<textarea name="_description" id="_description" value="demo" ></textarea>
<input type="text" name="productname" id="productname" />
<textarea name="description" id="description" ></textarea>
<input id="next" class="next" type="submit" name="next开发者_开发知识库" value="next" />
output:
productname = demo
description =
Help me get value this tag texterea
Textareas do not have a value attribute documentation (so do not use one). You have to put the value between the opening and closing tag <textarea> value here </textarea>
and also id's cannot start with _
documentaion so change that too, and it should work.
html
<input type="text" name="productname_" id="productname_" value="demo"/>
<textarea name="description_" id="description_">demo</textarea>
<input type="text" name="productname" id="productname" />
<textarea name="description" id="description" ></textarea>
javascript
$(document).ready(function(){
$('.next').click(function(){
$('input#productname').val($('input#productname_').val());
$('textarea#description').val($('textarea#description_').val());
});
});
demo at http://jsfiddle.net/gaby/Fmxyd/
I really don't know what yo are trying to do but instead of this:
$('input#productname').val($('input#_productname').val());
$('textarea#description').val($('textarea#_description').val());
You should just do:
$('#productname').val($('#_productname').val());
$('#description').val($('#_description').val());
If you have an ID, then thats all you need.
精彩评论