我有以下有效的脚本:
classes = $(this).attr("class").split('_');
If$(this)
的课程是:
class="billed_department_employee_client_code"
最终结果将如下所示:
["billed", "department", "employee", "client", "code"]
这正是我想要的,因为它允许我做这样的事情
console.log( classes[0] );
console.log( classes[1] );
console.log( classes[2] );
console.log( classes[3] );
是否可以从中删除单个值classes
并将其余值移回?
例如,
如果classes
包含department
,删除它。所以,如果它看起来像这样:
["billed", "department", "employee", "client", "code"]
它应该变成:
["billed", "employee", "client", "code"]
如何才能做到这一点?