0

我正在使用的替换功能在控制台中进行了测试,但它在模糊时根本不起作用。我该如何解决?

<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>
4

3 回答 3

2

您已删除空格,但您尚未将它们分配到任何位置:)

jQuery(document).ready(function(){
        jQuery('#item_keywords').unbind('blur').bind('blur',function(){
            $(this).val($(this).val().replace(/^\s+$/,""));
        });
    });
于 2011-02-18T11:33:21.080 回答
0

我正在使用:

        jQuery(document).ready(function(){
            jQuery('#business_email').unbind('blur').bind('blur',function(){
                var a = $(this).val().trim();
                $(this).val(a + '.');
                $(this).val(a);
            });
        });
于 2013-04-10T00:16:21.447 回答
0

你可以试试这个。

$(document).ready(function(){
    $("#mytextbox").blur(function(){
        $(this).val($(this).val().replace(/\s/g,''));
        console.log($(this).val());
    });
});
于 2015-04-10T02:07:16.850 回答