我想对从 attr 获取的变量使用 split 方法。
这是我正在尝试的代码:
$(document).ready(function() {
$('.some_divs').each(function() {
var id = $(this).attr('id');
var ida = id.spilt("_");
alert(ida[1]);
});
});
但是,当我运行我的代码时,它会抛出一个错误:Object id_1 has no method 'spilt'。
我尝试使用.toString和String()将变量转换为字符串。
可能我在这里遗漏了一些基本的东西。那会是什么?