jQuery字符串使用split()方法在空格后拆分字符串 [英] jQuery string split the string after the space using split() method

查看:65
本文介绍了jQuery字符串使用split()方法在空格后拆分字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码

  var str =$(this).attr('id');

这将给我带来== myid 5

   var str1 = myid
   var str2 = 5

我想要这样的东西..

i want something like this ..

如何使用拆分方法实现此目的

how to achieve this using split method

推荐答案

var str =$(this).attr('id');
var ret = str.split(" ");
var str1 = ret[0];
var str2 = ret[1];

这篇关于jQuery字符串使用split()方法在空格后拆分字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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