yoavf yoavf - 2 years ago 123
jQuery Question

Changing an element's ID with jQuery

I need to change an element's ID using jQuery.

Apparently these don't work:


I found out that I can make it happen with the following code:

jQuery(this).prev("li")show(function() {

But that doesn't seem right to me. There must be a better way, no? Also, in case there isn't, what other method can I use instead of show/hide or other effects? Obviously I don't want to show/hide or affect the element every time, just to change its ID.

(Yep, I'm a jQuery newbie.)


I can't use classes in this case, I must use IDs.

Answer Source

Your syntax is incorrect, you should pass the value as the second parameter:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download