占位符不适用于 ajax

placeholder is not working with ajax

我向我的函数发出 ajax 请求,当我回显它时,占位符不起作用看到这个 div 在循环中

php:

$info=NULL;
//loop-start
$info.='<div class="comment-part" id="commentBox'.$post_id.'"><textarea name="commentq'.$post_id.'" id="commentq'.$post_id.'" class="textarea-style1" placeholder="Comment.."  onkeydown="return runScript1(event,\''.$post_id.'\',\''.$cmt_id.'\')"> </textarea></div>
                   </div>';
echo $info;

//loop-end

js:

$('#data').append(html);

试试这个:你的代码有问题是你在“textarea”标签之间有 space,最后你添加了两个关闭的 div 但是你只有一个打开 div

$info.='<div class="comment-part" id="commentBox'.$post_id.'">
<textarea  name="commentq'.$post_id.'" id="commentq'.$post_id.'" class="textarea-style1" placeholder="Describe yourself here..." onkeydown="return runScript1(event,\''.$post_id.'\',\''.$cmt_id.'\')"></textarea></div>';

您在 <textarea> 标签之间有一个 space,因此它被插入到文本区域中。如果删除它,您将能够看到一个占位符。

$info.='<div class="comment-part" id="commentBox'.$post_id.'"><textarea name="commentq'.$post_id.'" id="commentq'.$post_id.'" class="textarea-style1" placeholder="Comment.."  onkeydown="return runScript1(event,\''.$post_id.'\',\''.$cmt_id.'\')"></textarea></div></div>';