Hi Erik, I am cloning a DIV container full of elements( selects, inputs and buttons), they all inherit the name of the original element, but to differentiate between all, I want to rename all the clones attributes sequentially, example
<div name= "container"> <input name="color"> <input name="house"> </dv> if I clone the whole container, the names should be: <div name= "container"> <input name="color"> <input name="house"> </dv> <div name= "container1"> <input name="color1"> <input name="house1"> </dv> ans so forth Thanks On Sep 26, 12:57 pm, "Erik Beeson" <[EMAIL PROTECTED]> wrote: > Rename them from what to what? To change the id of all selects, you can do: > > $('select').each(function() { > var oldId = $(this).attr('id'); > $(this).attr('id', oldId.substring(0, oldId.lastIndexOf('-'))); > > }); > > I'm still not sure what you actually want to do though. > > --Erik > > On 9/26/07, voltron <[EMAIL PROTECTED]> wrote: > > > > > I am trying to rename the ids and name attributes > > > On Sep 26, 10:06 am, "Erik Beeson" <[EMAIL PROTECTED]> wrote: > > > What are you trying to accomplish? > > > > --Erik > > > > On 9/26/07, voltron <[EMAIL PROTECTED]> wrote: > > > > > 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? > > > > > Thanks