Thursday, July 2, 2009

[jQuery] "Swapping" attributes with attr

Hi, I am trying to swap two attributes around, I am trying to achieve
something like this:

$(trigger).find('input').attr({value: img_id, name: $(this).attr('id')});

As you can see, I am trying to swap the value of the name attribute with the
value of the id attribute. The above code does not work, as $(this) is not
input field object.

Can anyone suggest a clean way in which I can do the above?
--
View this message in context: http://www.nabble.com/%22Swapping%22-attributes-with-attr-tp24308061s27240p24308061.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

No comments: