All Posts by Email, Once a Week

Media Temple logo

CSS-Tricks is brought to you in part by Media Temple, the web hosting that we both use and recommend.

Changing titles of multiple divs

  • # February 13, 2013 at 11:32 am


    Wondering if anyone might be able to give me a hand with the following. I’ve got a couple of divs that I want to let editors in a CMS change the Title attribute of. To do this I have created an editable area and a piece of jQuery that will grab the text from within this area and set the attr to it, which works fine.

    I’m slightly stuck though on how to do this for multiple divs. Can I use ‘this’ somehow, or should I use a for loop?

    In short:
    Take the h2 id=grabThis and append it to the title of the tab div

    []( “Check out the CodePen”)

    Thanks a lot!

    # February 13, 2013 at 12:03 pm

    This reply has been reported for inappropriate content.

    Use .each() and this, like so:

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed