相思资源网 Design By www.200059.com
<li id=""><span>***</span>评论<span>鲜果</span><a href="#message_area" onclick=" fillInMessageArea(this);">回复</a></li>
<li id=""><span>pizicai</span>评论<span>you</span><a href="#message_area" onclick=" fillInMessageArea(this);">回复</a></li>
<form action="">
<textarea onkeyup="rewrite();" rows="4" cols="30" id="message_area" name="message_area"></textarea>
<p></p>
<input type="submit"/>
<input class="not_write" id="input_rewrite" type="button" onclick="clearAll();"/>
</form>
</div>
<script type="text/javascript">
function fillInMessageArea(othis){
var text = othis.parentNode.childNodes[0].firstChild.nodeValue;
text = '回复' + text;
text += ':';
var me_area = $('#message_area');
me_area.val("");
me_area.val(text);
setFocus();
}
function clearAll(){
var me_area = $('#message_area');
var input = document.getElementById('input_rewrite');
if(me_area.attr('class') == 'not_write') return false;
var text = me_area.val();
text= text.replace(/(^\S+(:)+?)(\s*.+\s*)+/,"$1");
if(!text.match(/(.*?):/))
me_area.val("");
else
me_area.val(text);
setFocus();
hide_rewrite(input);
}
function rewrite(){
var me_area = $('#message_area');
var text = me_area.val();
var input = document.getElementById('input_rewrite');
if(text.match(/^\S+(:)+?(\s*.+\s*)+/) ||(!text.match(/(.*?):/)))
show_rewrite(input);
//input.value= "not null";
else
hide_rewrite(input);
if(text=='')
hide_rewrite(input);
//input.value = "null";
//alert('null');
}
function show_rewrite(input){
input.className = "can_rewrite";
}
function hide_rewrite(input){
input.className = "not_write";
}
function setFocus(){
esrc = document.getElementById('message_area');
//esrc.focus();
var rtextRange = "";
if(esrc.createTextRange){
rtextRange = esrc.createTextRange();
rtextRange.moveStart('character',esrc.value.length);
rtextRange.collapse(true);
rtextRange.select();
}
}
<li id=""><span>pizicai</span>评论<span>you</span><a href="#message_area" onclick=" fillInMessageArea(this);">回复</a></li>
<form action="">
<textarea onkeyup="rewrite();" rows="4" cols="30" id="message_area" name="message_area"></textarea>
<p></p>
<input type="submit"/>
<input class="not_write" id="input_rewrite" type="button" onclick="clearAll();"/>
</form>
</div>
<script type="text/javascript">
function fillInMessageArea(othis){
var text = othis.parentNode.childNodes[0].firstChild.nodeValue;
text = '回复' + text;
text += ':';
var me_area = $('#message_area');
me_area.val("");
me_area.val(text);
setFocus();
}
function clearAll(){
var me_area = $('#message_area');
var input = document.getElementById('input_rewrite');
if(me_area.attr('class') == 'not_write') return false;
var text = me_area.val();
text= text.replace(/(^\S+(:)+?)(\s*.+\s*)+/,"$1");
if(!text.match(/(.*?):/))
me_area.val("");
else
me_area.val(text);
setFocus();
hide_rewrite(input);
}
function rewrite(){
var me_area = $('#message_area');
var text = me_area.val();
var input = document.getElementById('input_rewrite');
if(text.match(/^\S+(:)+?(\s*.+\s*)+/) ||(!text.match(/(.*?):/)))
show_rewrite(input);
//input.value= "not null";
else
hide_rewrite(input);
if(text=='')
hide_rewrite(input);
//input.value = "null";
//alert('null');
}
function show_rewrite(input){
input.className = "can_rewrite";
}
function hide_rewrite(input){
input.className = "not_write";
}
function setFocus(){
esrc = document.getElementById('message_area');
//esrc.focus();
var rtextRange = "";
if(esrc.createTextRange){
rtextRange = esrc.createTextRange();
rtextRange.moveStart('character',esrc.value.length);
rtextRange.collapse(true);
rtextRange.select();
}
}
标签:
javascript,输入框
相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com
暂无javascript 清除输入框中的数据的评论...