Results 1 to 2 of 2

Thread: Change Div ID On Click

  1. #1
    Join Date
    Jan 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Change Div ID On Click

    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

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    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/
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •