日期:2014-05-16 浏览次数:20457 次
$("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>
------解决方案--------------------
这样:
<!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>
------解决方案--------------------