substr - How to get a certain sub_string in a sting using jquery -


i have routine produces id attributes on tag -- anywhere [1] [??]

i want able evaluate string , extract id ordinal using jquery.

here sample markup:

<div id="abc[1]"></div> <div id="abc[15]"></div> 

i know can this:

var n1=???.indexof("["); var n2=???.indexof("]"); var theid = $('#???').substr(n1,n2); 

but wondering how make work possible.

i want theid retrieve 1 or 15, etc.

try string.replace()

var n = $(el).attr('id'); var theid = n.replace('abc[', '').replace(']', ''); 

Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -