PDA

View Full Version : Change Div ID On Click



Rev
03-08-2011, 02:11 AM
Hi, I'm writing my first Firefox extension, and I'm having some problems.

The extension is basically a chrome-like new tab page for Firefox, and features swappable tiles. I used jQuery to get the tiles to swap, and they rely on a div id to be able to swap. I would like to set a link (or possibly a span or something) to change the div ID to lock it in place. Is this possible?

Thanks in advance.

Also, let me know if you'd be interested in joining the development effort, currently it's me and one other person. You can view the most up-to-date demo here: http://www.youtube.com/watch?v=RXtM3r6koTQ

Beverleyh
03-08-2011, 09:30 AM
You can add the ID attribute with attr()

$('p').attr('id', 'myID');

OR

$('.class').attr('id', 'myID');

Alternatively, you can use addClass/removeClass

$('p').removeClass('myClass noClass').addClass('yourClass');

OR

$('#div').addClass('myClass');

http://api.jquery.com/addClass/