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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:04:21+00:00 2026-05-19T16:04:21+00:00

I have a bookmarking feature on my site, when the person clicks a paragraph,

  • 0

I have a bookmarking feature on my site, when the person clicks a paragraph, the box that is already hovering over that paragraph that reads “bookmark this” inserts “sweet man” in place of “bookmark this”. so ‘bookmark this’ disappears and “sweet man” takes its place, how would i make it so when i click on the paragraph, it places 1 of 3 random phrases in there, lets say the 3 phrases are “success”, “sweet man”, and “awesome”. here’s a little bit of my code to show you where the random phrase would be placed.

 $('p').click(function (e) {
    var offset = $(this).offset();
     var top = offset.top

     if ($('#placeBookmark').hasClass('placing')) { 
      $('#placeBookmark').trigger('click')

    $('#bookmark').css({left: offset.left - 30, top: top}).show();
     $('#bookmarkThis').html('***SWEET MAN.***').delay(1000).fadeOut(400, function(){
        $(this).html('BOOKMARK THIS')
         })

    }
});

See where in my code it says “SWEET MAN.”, that’s where the 1 of 3 random phrases should be placed after the user clicks the paragraph.

THANK-YOU

  • 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-19T16:04:22+00:00Added an answer on May 19, 2026 at 4:04 pm
    $('p').click(function (e) {
      var offset = $(this).offset();
      var top = offset.top
    
      // list of phrases
      var phrases = ["success", "sweet man", "awesome"];
    
      if ($('#placeBookmark').hasClass('placing')) { 
        $('#placeBookmark').trigger('click')
    
        $('#bookmark').css({left: offset.left - 30, top: top}).show();
    
        // Selects a random phrase from the list.
        // Note that it doesn't require the length to be exactly three,
        // you can add and remove phrases above without changing this line.
        var selectedPhrase = phrases[Math.floor(Math.random() * phrases.length)]; 
    
        $('#bookmarkThis').html(selectedPhrase).delay(1000).fadeOut(400, function(){
          $(this).html('BOOKMARK THIS')
        })
      }
    });
    

    Edit

    As a separate function:

    var getRandomPhrase = function() {
      var phrases = ["success", "sweet man", "awesome"];
      return phrases[Math.floor(Math.random() * phrases.length)];
    };
    

    Or with the phrases are arguments:

    var getRandomPhrase = function(phrases) {
      return phrases[Math.floor(Math.random() * phrases.length)];
    };
    

    Use it like this:

    ...
    $('#bookmarkThis').html(getRandomPhrase()).delay(1000).fadeOut(400, function(){
    ...
    

    or, when phrases are used as arguments:

    ...
    $('#bookmarkThis').html(getRandomPhrase(["success", "sweet man", "awesome"])).delay(1000).fadeOut(400, function(){
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

we have an author that wants to be able to easily bookmark various articles
I have following function for bookmarking a website. This function is working in Firefox,
I have a simple bookmarking app that I am developing to learn Google App
Have a Facebook app that is failing as of this morning with the following
have written this little class, which generates a UUID every time an object of
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
I've searched through the site and haven't found a question/answer that quite answer my
Have a SQL problem, adding this model all works correctly, the problem is in
I have created a multi lingual dictionary app which reads several databases , I
I am new to URL rewriting and I have an .htaccess file that looks

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.