jQuery 删除模糊上的空格不起作用
我正在使用的替换功能可以正常工作,因为我已经在控制台中对其进行了测试,但它在模糊时根本不起作用。我该如何解决这个问题?
<script type="text/javascript">
//Ensure spaces are not entered between tags
jQuery(document).ready(function(){
jQuery('#item_keywords').blur(function(){
$(this).val().replace(/^\s+$/,"");
});
});
</script>
The replace function I'm using works as I've tested it in the console but it does not work at all on blur. How can I fix that?
<script type="text/javascript">
//Ensure spaces are not entered between tags
jQuery(document).ready(function(){
jQuery('#item_keywords').blur(function(){
$(this).val().replace(/^\s+$/,"");
});
});
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我正在使用:
I'm using:
你可以试试这个。
You can try this.
您已删除空格,但尚未将它们分配到任何位置:)
you have removed the spaces but u have not assigned them any where :)