Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript proper .append() syntax

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #29586
    noahgelman
    Participant

    I want to add a function to the end of an .append() statement. What would be the proper syntax for that? Am I even allowed to do that? I tried this and it didn’t seem to want to take. It appended the link properly, but the rest was a no go.

    Code:
    $(‘#target’).append(‘‘, function() {
    $(‘a’).addClass(‘blue’);
    #70705
    Chris Coyier
    Keymaster

    I can’t tell exactly from your code what you are trying to do, but it seems a bit like this:

    Code:
    $(‘#target’)
    .append(‘‘)
    .find(“a”)
    .addClass(‘blue’);
    #70942
    noahgelman
    Participant

    I didn’t have a specific goal in mind, that was just an example. It was mostly out of curiosity. I ran into an issue with reapplying java to new DOM elements and I couldn’t get .live() to cooperate so I figured if I could add a function to the end of an .append() I could just roll everything up into one.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.