Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8041581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:16:13+00:00 2026-06-05T04:16:13+00:00

I have the following script which works: classes = $(this).attr(class).split(‘_’); If $(this) ‘s class

  • 0

I have the following script which works:

classes = $(this).attr("class").split('_');

If $(this)‘s class was:

class="billed_department_employee_client_code"

The end result would look like this:

["billed", "department", "employee", "client", "code"] 

This is exactly what I want as it allows me to do stuff like this

console.log( classes[0] );
console.log( classes[1] );
console.log( classes[2] );
console.log( classes[3] );

Is it possible to remove a single value from classes and move the rest of the values back?

For example,

if classes contains department, remove it. So, if it looks like this:

["billed", "department", "employee", "client", "code"] 

it should become:

["billed", "employee", "client", "code"] 

How can this be done?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T04:16:14+00:00Added an answer on June 5, 2026 at 4:16 am

    You can use the splice() method.

    classes.splice(1, 1);
    

    will remove 1 item (second parameter) starting from index 1 (first parameter). If you don’t know the index, you can use indexOf() to find it.

    Some browsers do not support indexOf() so you can use the script from MDN to use it. You’ll also need to check to make sure indexOf() doesn’t return -1 (not found) as passing in negative parameter for index into splice() will cause it to remove items from the end of the array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this http://pastie.org/836744 script, which works outside the class completely fine, but it
I have the following lua script : module(modoo,package.seeall) foo=1 bar={12,34} Which works fine using
I have the following Ruby script that creates a Debian package, which works fine:
I have the following script which works perfectly until I regenerate the links .resultLink
I have the following script which works kind of... $(document).ready(function(){ // add or remove
I have the following script, which works successfully till the last file slice is
I have the following script which works fine: $.ajax({ url: 'serverside_script', type: 'GET', dataType:
I have the following script which works with a 1 dimensional array. Is it
I have the following script which works very will: http://jsfiddle.net/oshirowanen/uUAqe/ I just need to
I have the following script which works almost perfectly: http://jsfiddle.net/oshirowanen/uUAqe/ I just need it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.