You have previously shared a jquery plugin in the DOM that is automatically separated by a user's name and name into the form in a table. Because of the needs of the project, a method that automatically splits at the client, but does not need to present the split results to the user, is written in a separate way, Post it and share the conversation with you.
$.extend ({splitname:function (fullname) {var hyphenated = [' Ouyang ', ' Too history ', ' Duanmu ', ' Officer ', ' Sima ', ' Oriental ', ' solitary ', ' nangong ', ' As soon as ', ' wenren ', ' xia-hou ', ' Zhuge ', ' yuchisi ', ' Ram ', ' Hector ', ' Dan Tai ', ' Huang Fu ', ' huizong ', ' Puyang ', ' Gong ye ', ' Tai tert ', ' Shen ', ' Gongsun ', ' Murong ', ' Dongsun ', ' clock away ', ' grandson ', ' nonfictional ', ' Castle ', ' Stu ', ' Sainus ', ' sikong ', ' ru Yan ', ' Lu Qiu ', ' che ', ' Shang ', ' vacant ', ' witch ', ' Percy ', ' Zhuan sun ', ' Soil 驷 ', ' Gong Liang ', ' carved lacquer ', ' Le Zheng ', ' kill Father ', ' Guliangzhuan ', ' Tuoba ', ' pinch gu ', ' yuan ', ' Make fox ', ' Duan Gan ', ' Barry ', ' Huyan ', ' Dong Guo ', ' South Gate ', ' goat tongue ', ' micro ', ' Male ', ' Gong Yu ', ' public instrument ', ' according ', ' Gong Zhong ', ' on the public ', ' Public gate ', ' Male mountain ', ' public ', ' left Mound ', ' Male ', ' Simon ', ' Male ', ' V ', ' gong ', ' Guan
Qiu ', ' Gong Xi ', ' Nam Rong ', ' Dong Li ', ' Orient House ', ' Zhong Long ', ' Zoshu ', ' sang ', ' Jimo ', ' Da Yu ', ' Chu ';
var vlength = fullname.length; var lastname = ', FirstName = ';//Last name, after name if (Vlength > 2) {var pretwowords = Fullname.sub STR (0, 2);//Take the first two words that are named and see if they are in the hyphenated library if ($.inarray (pretwowords, hyphenated) >-1) {Lastna
me = pretwowords;
FirstName = FULLNAME.SUBSTR (2); }else{LastName = fullname.substr (0, 1);
FirstName = FULLNAME.SUBSTR (1);
}}else if (vlength = = 2) {//Full name only two words, before one for last name, later for name LastName = FULLNAME.SUBSTR (0, 1);
FirstName = FULLNAME.SUBSTR (1);
}else{LastName = fullname;
return [LastName, FirstName]; }
});
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/jquery/