SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member Niki Liu's Avatar
    Join Date
    Apr 2007
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Targeting End Tags

    Is there any way to target, say, a free-floating </div> tag in JavaScript?
    Niki

  2. #2
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    From what I know, an HTML document is mainly built out of text nodes (which can be white space or tabs or newlines) and element nodes. I don't believe you can actually target an end tag. Are yo u looking to add something to an element but before it ends? If so appendChild would do. If not, describe what you want to do.

  3. #3
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    In any case, you shouldn't have "free-floating" end tags. If there's anything that can deal with this it's innerHTML. So you could change a string like this:
    HTML Code:
    <div>Text</div>
    into:
    HTML Code:
    <div>Text</p>
    by using string manipulation functions.

    But that would be completely pointless because it's invalid HTML.

  4. #4
    SitePoint Member Niki Liu's Avatar
    Join Date
    Apr 2007
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I realize that free-floating div tags is invalid HTML. I'm all for validity of my documents, and would object to any invalid code.

    The reason I wanted to see if I could do this is because I want to get rid of a free-floating div tag on a WordPress.com blog I have. Since it's hosted on WordPress.com...I obviously didn't code the theme, and since I don't want to spend money to edit my code, I thought maybe I could just use JavaScript to solve the problem. I would host my own blog, but I trust WP more than I do myself. I change things too much.

    However, now I realize that even by manipulating the DOM with JavaScript, it's not going to effect the actual source code, so it won't validate anyway.
    Last edited by Niki Liu; Feb 6, 2008 at 23:32.
    Niki


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
  •