sephiith
sephiith

Reputation: 1197

Remove first character with jQuery

How would I go about removing the first character from this.className in the below line? The first variable will be _ and then a number. I just want the number to be assigned to className.

className = this.className; 

Furthermore I am changing "$('.inter').html(window[link[className]]);" to use an array instead of the className variable. Is the below code the correct way to use an array with the index as a variable?

$('.inter').html(window[link[className]]);

Upvotes: 20

Views: 72607

Answers (1)

Benjamin Gruenbaum
Benjamin Gruenbaum

Reputation: 276306

No need to use jQuery for that, just plain ol' javascript using .substring

var trimmed = this.className.substring(1);

Upvotes: 83

Related Questions