占位符不适用于 Ajax

placeholder is not working with ajax

本文关键字:Ajax 适用于 不适用 占位符      更新时间:2023-09-26

我向我的函数发出 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>标签之间有一个空格,因此将其插入到文本区域中。如果将其删除,您将能够看到占位符。

$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>';

试试这个:你的代码问题是你在"textarea"标签之间有空格,最后你添加了两个接近的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>';
相关文章: