获取textarea文本框的值 怎么用jQuery获取页面上所有类型为textarea但name包含“question”的文本框的值? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $(textarea[name='question']).each(function(){$(this).attr("value");})试试 $("textarea[name*='question']").each( function() { alert($(this).val());}); <!DOCTYPE HTML><html lang=""><head> <meta charset="gbk"> <title></title> <script src="http://code.jquery.com/jquery-latest.js"></script></head><body> <textarea name="question">1</textarea> <textarea name="question">2</textarea> <textarea name="question">3</textarea> <textarea name="ques123tion">4</textarea> <textarea name="question123">5</textarea> <script type="text/javascript"> $('textarea[name*=question]').each(function(){ alert( this.value ) }) </script></body></html>这个是包含question, question123也匹配楼主是要等于的 还是包含的?等于就直接textarea[name=question] 这样:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <title>test</title> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script></head><body><textarea name="questionName" id="" cols="30" rows="10">111</textarea><textarea name="Namequestion" id="" cols="30" rows="10">222</textarea><textarea name="Name" id="" cols="30" rows="10">333</textarea><script type="text/javascript"> var tarea = $("textarea[name*='question']"); tarea.each(function(){ console.log($(this).val()); });</script></body></html> $("textarea[name='question']").each(function(){alert($(this).attr("value"));}) innerHTML的转义字符在WIN7下复制出来后都不见了 页面rewrite报JS错误 关于this 的指向问题 HTMLDOM与XMLDOM的区别 jsp中,怎样上传图片!! 如何设置一个del按钮,能删除一整个表格 页面刷新问题 通过OPEN打开窗口,如何设置打开的窗口的标题 关于转向! 请大家帮忙,在线等:如何在表格栏中显示复选框的值? jquery控制div的相对位置时不同浏览器的兼容 如何遍历这个json数组
alert($(this).val());
});
<!DOCTYPE HTML>
<html lang="">
<head>
<meta charset="gbk">
<title></title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<textarea name="question">1</textarea>
<textarea name="question">2</textarea>
<textarea name="question">3</textarea>
<textarea name="ques123tion">4</textarea>
<textarea name="question123">5</textarea>
<script type="text/javascript">
$('textarea[name*=question]').each(function(){
alert( this.value )
})
</script>
</body>
</html>
这个是包含question, question123也匹配
楼主是要等于的 还是包含的?
等于就直接textarea[name=question]
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>test</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
</head>
<body>
<textarea name="questionName" id="" cols="30" rows="10">111</textarea>
<textarea name="Namequestion" id="" cols="30" rows="10">222</textarea>
<textarea name="Name" id="" cols="30" rows="10">333</textarea>
<script type="text/javascript">
var tarea = $("textarea[name*='question']");
tarea.each(function(){
console.log($(this).val());
});
</script>
</body>
</html>