Thanks guys, I used a mixture of both your suggestions:
var ident = String(this.name);
changed= ident.substring(0 ,ident.lastIndexOf('-')+1) + suffix;
$(this).removeAttr("id");
$(this).removeAttr("name");
this.name += changed;
this.id += changed;
$(this).attr("clone", changed);
On Sep 26,
> I have tags like this:
>
>
>
> 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).
How about something like (untested):
$('#container').clone().attr('id',
'container'+idx).find('*').each(function() {
this.name += idx;
this.id += idx
}).end().appendTo(...);
How you deal with 'idx' is up to you. So that's: select the element with ID
'container', clone it, update the clone's i
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
if I clone the whole container, the names should be:
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 <
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:
> >
> >
>
> > since the ids are variable in length,
What are you trying to accomplish?
--Erik
On 9/26/07, voltron <[EMAIL PROTECTED]> wrote:
>
>
> I have tags like this:
>
>
>
> 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 s
7 matches
Mail list logo