获取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"));}) 我想实现 巧学巧用 文字滚动 js哪里出错了? 请教高手,关于setInterval在类中的应用 急!高分求解!在线等待!!! 关于htc文件在jsp环境中调用的问题 jQuery_File_Upload数据库应用--php想大家帮帮忙 编辑器错误!! 哪位大哥给看看。。。 如何用javascript实现全选,多选,复选框的name是不同的值,譬如从a1,a2,a3,.....an 请教关于错误处理的问题! 求代码,大家帮我,谢谢. 帮忙看下这段jQuery代码为啥不起作用 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>