嗨我得到的標題屬性「編織,主」。目前,var認爲它是一個詞是否有一些符號,如「,」,這將使var處理它們在一個數組中?標題屬性數組
標題= 「針織,主營」
var titleIs = [this.title];
alert(titleIs.length); // at the moment this is 1
嗨我得到的標題屬性「編織,主」。目前,var認爲它是一個詞是否有一些符號,如「,」,這將使var處理它們在一個數組中?標題屬性數組
標題= 「針織,主營」
var titleIs = [this.title];
alert(titleIs.length); // at the moment this is 1
試試這個:
var titles = this.title.split(/,\s?/)
使用JavaScript split
功能
當然,你的意思是鏈接http://www.ecma-international.org/ecma-262/5.1/#sec-15.5.4.14或https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/split – 2013-04-04 21:51:35
嘗試使用此
var titleIs = this.title; //if use this.title like string not array [this.title]
alert(titleIs.split(/,\s?/));
喜歡的東西['分裂()'](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/split)? – summea 2013-04-04 21:50:12