jQuery: The Write Less, Do More JavaScript Library

 « Return to Thread: "Swapping" attributes with attr

"Swapping" attributes with attr

by Hanpan :: Rate this Message:

Reply to Author | View in Thread

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?

 « Return to Thread: "Swapping" attributes with attr