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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:44:40+00:00 2026-05-25T00:44:40+00:00

I have this code, and I want on click on div with favoriteButton class,

  • 0

I have this code, and I want on click on div with favoriteButton class, text in current (this) <a> and src of current img tag to be changed.
Changing text in <a> work fine but image not work.
I try to put another as child of first and code work fine, only in nested img not work

$('.favoriteButton').click(function(e){

    $(this).find('.aclass').text("yeeee");
    $(this).find('.imgclass').attr("src", "remove_favorit.png");

    e.preventDefault(); 

});


    <div class="favoriteButton" >                                    
     <a class="aclass" href="">Text
       <img class="imgclass" src="add_heart.png">
     </a>
    </div>
    <div class="favoriteButton" >                                    
     <a class="aclass"  href="">Text
       <img class="imgclass" src="add_heart.png">
     </a>
     </div>

Can some one help me how to solve that using JQuery

Thanks

  • 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-25T00:44:40+00:00Added an answer on May 25, 2026 at 12:44 am

    That’s because the image is inside the link, so when you change the .text() value of the link, the image disappears. To solve this, take the image outside of the link, or cache it and append it after you change the text.

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

Sidebar

Related Questions

I have this HTML code: <div id=content> <div class=profile_photo> <img style=float:left;margin-right:7px; src=http://gravatar.com/avatar/53566ac91a169b353a78b329bdd35c95?s=50&d=identicon class=profile_img alt={username}/>
hi i have this html code : <div id=#div><a href=>Test</a></div> i want attach click
when I want to remove div element, I have the following code: <div class='text-field'>
I have this html code <div> <p>MY Text <a href=url>Text</a> </p> </div> I need
i have this html code: <div id=ht_key class=ht_all> <div class=ht_bottom> <div class=ht_bottom_p> <span class=ht_bottom_o>
I have this code: $('.b-icon.b-icon_del').click(function(e) { showConfirmDialog('Are you sure you want to delete this
I have this code : #bottom-div { z-index:999 } <input type=text id=main /> <div
I have this JQuery code: $(div.notification).live(click, function(){ window.location=$(this).find(a).attr(href); var myId = $(this).attr(id); $.post(/videos/selected_notification.js, myId);
I have this bit of code. What I want is when I click on
I have this code: <div id=star-rating> <script type=text/javascript> $(function(){ $('#star-rating form').submit(function(){ $('.test',this).html(''); $('input',this).each(function(){ if(this.checked)

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.