怎样用js方法过滤html等代码

怎样用js方法过滤html等代码,第1张

<input type="text" id="theOne" value="">

<input type="button" onclick="NoHtml()" value="过滤html标签">

<script>

function NoHtml(){

var t=document.getElementById("theOne").value

document.getElementById("theOne").value=t.replace(/<\/?[^>]*>/g,'')

}

</script>

一般都是先排序再渲染,可以是服务器端直接输出排序结果直接渲染,也可以获取数据之后排序完再渲染。

如果是渲染完再排序那么页面会发生”闪现“,严重点会出现页面短暂混乱,如果列表很长那么页面将”自己动起来“,很吓人的。比起页面”自己动起来“宁愿让它短暂的"转圈圈"一点点加载。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/8298463.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-15
下一篇 2023-04-15

发表评论

登录后才能评论

评论列表(0条)

保存