IE8 and JQuery's trim()

后端 未结 5 1233
醉梦人生
醉梦人生 2020-12-02 09:07

I am making use of trim() like so:

if($(\'#group_field\').val().trim()!=\'\'){

Where group_field is an input element of type t

5条回答
  •  我在风中等你
    2020-12-02 09:42

    To globally trim input with type text using jQuery:

    /**
     * Trim the site input[type=text] fields globally by removing any whitespace from the
     * beginning and end of a string on input .blur()
     */
    $('input[type=text]').blur(function(){
        $(this).val($.trim($(this).val()));
    });
    

提交回复
热议问题