title属性阵列 [英] title attribute array

查看:162
本文介绍了title属性阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了title属性针织,主营。目前的无功认为,这是一个字也像一些符号,这将使VAR处理他们在一个数组?

标题=针织,主营

  VAR titleIs = [this.title];
警报(titleIs.length); //此刻这是1


解决方案

试试这个:

  VAR标题= this.title.split(/,\\ S /?)

Hi I'm getting the title attribute "Knit, Main". At the moment the var thinks that it is one word is there some symbol like "," that will make the var handle them in an array?

title="Knit, Main"

var titleIs = [this.title];
alert(titleIs.length); // at the moment this is 1

解决方案

Try this:

var titles = this.title.split(/,\s?/)

这篇关于title属性阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆