I am having a click handler for three buttons and inside this handler I want to extract ID of the button clicked. I have a line of code like this:
$('#switch button').click(function(){
var class=this.id.split('-')[1];
// rest of the code
});
I do understand the split method, but can’t understand [1] index in the end?
Assume that I have a id named say switch-default.
It is the index of the element in the newly created array, so
[1]refers to the second element. To make it clear:See: