Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8512333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:15:04+00:00 2026-06-11T04:15:04+00:00

I have a value passed via a # in the url this is the

  • 0

I have a value passed via a # in the url this is the class name of a checkbox what i am trying to do is get the value of that checkbox ID using jQuery

// get hashtag value
if(self.document.location.hash){
var urlhash = self.document.location.hash;
var hashtagval = self.document.location.hash.replace("#","");

// get id of element from hashtagval (class name)
var counter = $('.'+hashtagval).attr('id');
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:15:07+00:00Added an answer on June 11, 2026 at 4:15 am

    OK, I tested it and it works fine with adding #a and #b to the hash.

    Beside you are abusing the hash attribute. The hash attribute is used to define a viewstate of the page (e.g. the screen should move to this paragraph) not to store some local varibles, which are then used for application logic!

    <!doctype html>
        <html>
            <head>
                <meta charset="utf-8">
                <title>Demo</title>
                <script src="jquery.js"></script>
                <script>
                    $(document).ready(function() {
                        var change = true;
                        $('#ba').click(function() {
                            // get hashtag value
                            if(self.document.location.hash) {
                                var urlhash = self.document.location.hash;
                                var hashtagval = self.document.location.hash.replace("#", "");
    
                                // get id of element from hashtagval (class name)
                                var id = $('.' + hashtagval).attr('id');
                                $('body').append('<h1>id=' + id);
                            }
                        });
                    });
                </script>
            </head>
            <body>
    
                <button type="button" id="ba" >
                    Click Me!
                </button>
    
                <div>
                    <p id="foundthisthing" class="a">
                        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
                    </p>
                    <p id="thisworkstoo"class="b">
                        eafdsaf dsa dgsf dgadg dfg dagfadgLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
                    </p>
                </div>
            </body>
        </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an if statement that's condition is passed to this implementation file via
I have a range of parameters that are passed via jQuery Ajax to an
I have a page with a textbox that passed a value through a stored
I have a helper class that is passed an array of values that is
im working on a old code and i have this warning message: Passed-by-value struct
So I have a PHP class called router that takes the URL and explodes
I have a PHP script called customers.php that is passed a parameter via the
I have a function which checks the passed value and returns false or true,
Lets say I have a function where the parameter is passed by value instead
I have a universal data type, which is passed by value, but does not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.