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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:22:18+00:00 2026-05-11T20:22:18+00:00

I am experimenting with Jetpack and I would like to parse all the years

  • 0

I am experimenting with Jetpack and I would like to parse all the years in a given html page and then wrap the year with a link to the Wiki page. I tried the code in jquery and there it works but now I am using it in Jetpack and it gives an error $(doc).replace is not a function. I am definitely new to Jquery / Jetpack so maybe I am missing something really easy but your help is much appreciated.

EDIT: I have tried the suggestions but I am still stuck. The weird thing is that this

JQuery function works:

(function($) {
    $.fn.clickUrl = function() {  
            var regexp = /([1-2][0-9][0-9][0-9])/gi;
            this.each(function() {
            $(this).html(
                  $(this).html().replace(regexp,'<ahref=\"http://nl.wikipedia.org/wiki/$1\">$1<\/a>')
            );
        });
    return $(this);
    }
})(jQuery);

and basically, I would like to ‘port’ this function to Jetpack.

This is the ‘old’ non-working port of my JQuery function to Jetpack:

jetpack.statusBar.append({  
    html: "Hyperlink Years",  
    width: 80,  
    onReady: function(widget){  
        $(widget).click(function(){  
        var regexp = /([1-2][0-9][0-9][0-9])/gi;
        var doc = jetpack.tabs.focused.contentDocument;
            $(doc).each(function() {
            $(this).html(
                    $(doc).replace(regexp,'<a href=\"http://nl.wikipedia.org/wiki/$1\">$1<\/a>'));
            });
       return $(doc); 
     });  
   }  

});
  • 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-05-11T20:22:18+00:00Added an answer on May 11, 2026 at 8:22 pm

    I’m not familiar with jetpack, but your jquery seems to be quite messed up.

    If “doc” is an HTML document, then doing $(doc).each() doesn’t really make sense. It would only loop once, and “this” would be the same as doc.

    Then later you are doing $(doc).replace(regexp, …), but replace() is not a jquery function. You might have wanted to do .html().replace(regexp, …); HOWEVER, I do not recommend doing this because it will not work – you will just end up replacing any numbers in the document, even if they are part of another URL or the HTML of the page.

    For more information, refer to this question or google for jquery text nodes:
    Find text string using jQuery?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm experimenting with using couchdb as a message store and would like to report
I am experimenting with following code: http://www.jsresources.org/examples/MidiNote.java.html to operate my Novation Launchpad MIDI Controller.
I recently started experimenting with Python decorators (and higher-order functions) because it looked like
I have been experimenting some problems with the fully distributed version. First of all
Experimenting with Scala... I'm trying to define something analogous to the @ hack in
While experimenting with this question on collections in Spring.NET , I discovered that Spring
While experimenting with pixel shaders in WPF I decided to draw some pixels onto
When experimenting with (embedded) Apache Derby DB, I noticed that a fresh database, with
I experimenting with twitter streaming API, I use Phirehose to connect to twitter and
I have been experimenting with woopra.com A web analytics tool. Which requires a piece

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.