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

  • SEARCH
  • Home
  • 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 8256511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:52:50+00:00 2026-06-08T01:52:50+00:00

Im trying to extract the value of a single $_GET variable contained in a

  • 0

Im trying to extract the value of a single $_GET variable contained in a link.

So the html looks like:

<div class="news_item"><a href="http://example.com/?p=51">Title</a></div>

And I am trying to pull out just ’51’ from this url using JS:

<script>
        function GetURLParameter(sParam, URL) {
            var sURLVariables = URL.split('&');
            for (var i = 0; i < sURLVariables.length; i++) 
            {
                var sParameterName = sURLVariables[i].split('=');
                if (sParameterName[0] == sParam) 
                {
                    return sParameterName[1];
                }
            }
         };

        $('.news_item a').click(function(e) {
            e.preventDefault();
            var URL = $(this).val('href');
            var sParam = 'p';
            var ID = GetURLParameter(sParam, URL);
            alert(ID);
        });


    </script>

When I click on the link I get the following error: Uncaught TypeError: Object [object Object] has no method 'split' Any ideas what is happening? I can’t figure out what I have done wrong..

  • 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-08T01:52:52+00:00Added an answer on June 8, 2026 at 1:52 am

    Try – http://jsfiddle.net/6W4Rw/

    $("a").on("click", function(e) {
        e.preventDefault();
        alert( $(this).attr("href").split("=")[1] );
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to extract a value from a string. The string looks like this:
I am trying to extract the content of a single "value" attribute in a
I'm trying to extract a value through Javascript from an element's CSS3 attribute such
I am trying to extract a value from an xml element, located in an
I am trying to extract the port from a given in_addr value in windows.
I'm trying to extract the mileage value from different ebay pages but I'm stuck
I am trying to extract a value of a node in xml. I am
I am trying to write a template function which will extract the value of
I am trying to extract character value from UTF-8 format. Suppose I have two
I am trying to extract the value attribute of XML tag in Tridion rich

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.