使用jquery中的按钮在php的foreach中获取textarea的val()
使用jquery中的按钮在php的foreach中获取textarea的val()使用jquery中的按钮在php的foreach中获取textarea的val(),php,jquery,Php,Jquery,使用jquery中的按钮在php的foreach中获取textarea的val() $(document).ready(function(){ $('.boton_responder').click(function(){ var cod = $(this).attr("name"); var texto = $('input[name="'+cod+'"]' ).val(); console.log(texto); }
$(document).ready(function(){
$('.boton_responder').click(function(){
var cod = $(this).attr("name");
var texto = $('input[name="'+cod+'"]' ).val();
console.log(texto);
});
});
它适用于带有php和jquery的html注释系统,只是当管理员登录系统时,显示所有没有答案的注释,并显示一个字段textarea,管理员将为其编写答案
因此,我停止在这里,因为在console.log in texto show indefined中,但“cod”show fine值是不正确的。尝试:
var texto = $('textarea[name="'+cod+'"]').val();