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 8840269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:25:40+00:00 2026-06-14T10:25:40+00:00

I am using a bitly script to shorten urls and insert the resulits into

  • 0

I am using a bitly script to shorten urls and insert the resulits into a span tag.

Using jquery, how would I loop through the following list ids and replace the long url with the shortened one.

<ul class="vertical-list list-parent">
    <li id="license_key_0">
      <div class="primary two-quarter unit-link">
          <span>http://localhost:3000/projects/313f7f5586b39cd9bf7a894894564036</span>
      </div>
    </li>
    <li id="license_key_1">
    <div class="primary two-quarter unit-link">
         <span>http://localhost:3000/projects/287a990d17b680fe410329cb95af89b9</span>
   </div>
  </li>
<li id="license_key_2">
  <div class="primary two-quarter unit-link">
       <span>http://localhost:3000/projects/ff381cdb94070e1903c5f6fddc31b148</span>
  </div> 
</li>
  </ul>

The jquery:

(function ($j) {
      function get_short_url(long_url, login, api_key, func) {
        $j.getJSON(
          "http://api.bitly.com/v3/shorten?callback=?", {
          "format": "json",
          "apiKey": api_key,
          "login": login,
          "longUrl": long_url
        },
        function (response) {
          func(response.data.url);
        });
      }

      var login = "my_login";
      var api_key = "my_api_key";
      var long_url = "m";

      get_short_url(long_url, login, api_key, function (short_url) {
        console.log(short_url);
      });

    })(jQuery);
  • 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-14T10:25:41+00:00Added an answer on June 14, 2026 at 10:25 am

    use .each() jquery function to iterate over the selector:

    $('ul .unit-link span').each(
        function(index){
          var long_url = $(this).text();
          get_short_url(long_url, login, api_key, function (short_url) {
              console.log(short_url);
          });
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using bitlyj snapshot jar to shorten URLs from the following link. http://code.google.com/p/bitlyj/downloads/list
I tried to call bit.ly API using this jQuery script: $.get('http://api.bit.ly/shorten?login=bitlyapidemo&apiKey=R_0da49e0a9118ff35f52f629d2d71bf07&version=2.0.1&longUrl=www.wordpress.com', function(data) { alert(data);
I am using the bitbly API to shorten urls. here is a snippet of
I'm currently using the ruby-bitly gem to shorten links in a Rails app; however,
I'm using jQuery and cycle.js to fade through some images on this site. On
I'm using the bit.ly url shortening service to shorten certain url's being sent to
I am trying to call to the bit.ly URL shortening service using jQuery with
I have tried to introduce myself into tableless layouts using divs. A first try
I'm dynamically adding some li s to an unordered list using jQuery. They are
Newbie question again... I already have the following code for making links shortened using

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.