[jQuery] Re: "Swapping" attributes with attr

2009-07-02 Thread Ricardo
attr() accepts a function as the second argument: $(trigger).find('input').val(img_id).attr('name', function(){ return this.id }); On Jul 2, 11:45 am, Sceneshift wrote: > Hi, I am trying to swap two attributes around, I am trying to achieve > something like this: > > $(trigger).find('input').at

[jQuery] Re: "Swapping" attributes with attr

2009-07-02 Thread Charlie
assuming $(trigger) is a valid selector, this should work: var theValue = $(trigger).find('input').val(); $(trigger).find('input').attr('id',theValue'); Sceneshift wrote: Hi, I am trying to swap two attributes around, I am trying to achieve something like this: $(trigger).find('input'