> I have tags like this: > <select id="academic_from_month-0" > > <select id="academic_till_month-0" > > > since the ids are variable in length, I would have to find out where > the lastindex() of "-" is remove that and replace it it with the new > value. My problem is the syntax, is there some kind of Jquery way to > do this?
$('select).each(function() { id=$(this).attr('id'); //number after '-', useless if you dont need number number=id.substring(id.lastIndexOf('-')+1); //new value that you want to put after '-' newvalue='1234567'; changed=id.substring(0,lastIndexOf('-')+1)+newvalue; } or something like that (I didnt check that) :) Regards Michael