SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jul 2010
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Get HTML element ID from URL

    Let's say I have a URL like this:

    Code:
    http://domain.com/#ID
    How do I fetch the ID with jQuery? What I want to do is to fetch it and then display content in a <div> that depends on the ID value. Do you know how to do that?

    Thanks and best regards folks!

  2. #2
    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)
    Convenient because window.location.hash will just return "#id" so you can use it directly as a jquery selector:

    Code:
    $(window.location.hash).html('content to go in DIV');


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
  •