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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:19:41+00:00 2026-05-13T19:19:41+00:00

I trying to use the toggle function, to change the background and href of

  • 0

I trying to use the toggle function, to change the background and href of a link, so far I have this code,

$('a.loveIt').toggle(
        function() {
         var url = $(this).attr('href');
         $.ajax({
            url:url,
            type:"POST",
            success:function(){
                //alert("hello");
                $('p#loveIt').append(
                    "<a class='lovedIt' href='<?php base_url()."welcome/noMore/".$row['contentId'];?>'>Change It</a>"
                )
                $('div#wrapper').append(
                    "<div id='flashAdded'><p>The content has been added to your content</p></div>"
                )
                $("#flashAdded").animate({marginTop:"0px"}, 1500);
                setTimeout(function () {$("#flashAdded").animate({marginTop:"-46px"}, 1500);}, 2000);
                $('.loveIt').removeClass('loveIt').addClass('lovedIt');
            }
         });
         return false
        },
        function() {
        alert(id);
            $(this).removeClass('lovedIt').addClass('loveIt')
        });

The URL variable that is being set in the first function is ‘welcome/loveThis/5’ 5 is different per article as it is the articles ID, on click the link I remove a class and add a class, but I also need to change the link href to ‘welcome/noMore/5’ (or whatever the id maybe).

Is this possible?

  • 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-13T19:19:41+00:00Added an answer on May 13, 2026 at 7:19 pm

    I think you could try

    var link = $('.loveIt');
    link.removeClass('loveIt').addClass('lovedIt').attr('href', link.attr('href').replace('loveThis', 'noMore'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to use this following script to load a page so that I can
Im trying to use the DotNetOpenAuth library for openid authentication. I have used the
I asked this question earlier today. After trying out suggestions from a few members,
I have been trying to make radio buttons without the dot which toggles. I
Im trying to use my web Config files in Silverlight. I've put the following
Im trying to use PHP mail on my local computer, but its just not
When trying to use i18n in rails I get the following undesired output. The
I am using jQuery and Joomla. Sinca I need to use jQuery.noConlict() due to
Good morning , In Scott Meyers book Effective STL, Mr Meyers explains how the
In my program(C++, WinAPI), I wanted to simulate pressing some existing hotkeys set in

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.