I have a input field with a name attribute like field[subkey][subkey2]
How can I get the last part of the string, subkey2 in javascript?
$('input').each(function(){
var name = $(this).attr('name');
// here I need only the last part of "name"
});
First thoughts:
JS Fiddle demo.
Alternatively:
JS Fiddle demo.
If you want to use jQuery to select the relevant elements:
JS Fiddle demo.
References:
string.lastIndexOf().string.split.string.substring().