jQuery删除模糊上的空格不起作用 [英] jQuery remove spaces on blur not working
本文介绍了jQuery删除模糊上的空格不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用的替换功能已经在控制台中对其进行了测试,但是在模糊时它根本不起作用.我该如何解决?
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>
推荐答案
您已删除空格,但您尚未在任何位置分配它们:)
you have removed the spaces but u have not assigned them any where :)
jQuery(document).ready(function(){
jQuery('#item_keywords').unbind('blur').bind('blur',function(){
$(this).val($(this).val().replace(/^\s+$/,""));
});
});
这篇关于jQuery删除模糊上的空格不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文