![](/img/trans.png)
[英]How can I stop Firefox from caching the contents of a textarea on localhost?
[英]How can I stop the textarea from disappearing?
我有一个添加用户评论的表格:
<textarea name="comment" id="comment_box" placeholder="Share your thoughts" cols="175" rows="9"></textarea>
<input type="button" name="add_comment" id="add_comment_button" value="Add comment"
onclick="add_comment_js('comment_form','{$type}')">
一旦我点击按钮“添加评论”,文本区域就消失了(我想使用jquery),其中没有CSS文件。
还链接了一个很大的functions.js文件,我怀疑javascript文件中的此方法与消失有关:
function add_comment_js(form_id,type)
{
var formObjectData = $('#'+form_id).serialize()+'&mode=add_comment';
$.post(page,formObjectData,
function(data)
{
if(!data)
alert("No data");
else
{
if(data.cid)
{
get_the_comment(data.cid,"#latest_comment_container");
$("#"+form_id).slideUp();
}
}
},'json');
}
为什么在发布评论后隐藏文本区域? 怎么了?
$("#"+form_id).slideUp();
运行此函数时隐藏表单。 删除该行,文本区域应保持不变。 Slideup“以滑动方式隐藏匹配的元素”。 这是该函数的jQuery API参考 。
从您的代码中删除此行
$("#"+form_id).slideUp();
最终结果应为:
function add_comment_js(form_id,type)
{
var formObjectData = $('#'+form_id).serialize()+'&mode=add_comment';
$.post(page,formObjectData,
function(data)
{
if(!data)
alert("No data");
else
{
if(data.cid)
{
get_the_comment(data.cid,"#latest_comment_container");
}
}
},'json');
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.