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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:01:47+00:00 2026-05-11T02:01:47+00:00

I am new to JQuery. I’m reading JQuery in action, but only up to

  • 0

I am new to JQuery. I’m reading JQuery in action, but only up to page 39 and need some quick help!

Please note: I’m simplifying my actual requirement, so what I’m asking for may sound odd but I’m just tryin to get to the crux of the JQuery expression and not my situation (related to an animation plugin).

I have my HTML code (which is generated and I dont want to change) :

<div class='favorite'>    <div>           <a href='http://www.stackoverflow.com'>Stackoverflow</a>    </div> </div> 

Now that I want to do is insert the text ‘(favorite)’ INSIDE the A tag after the current contents. Or in other words as the last child of the <a>.

<div class='favorite'>    <div>           <a href='http://www.stackoverflow.com'>Stackoverflow (favorite)</a>    </div> </div> 

The best I have so far is this :

$('<span> (favorite)</span>').insertAfter('.favorite div a'); 

Of course this ends up putting the (favorite) text OUTSIDE the A link and it wont be underlined (which I want).

I need to somehow say .parent().lastChild() but I’m not quite sure how to do that.

Note: I had to put <span> in because otherwise it didnt see it as ‘insertable’ text. I’m sure there a way around that too but thats a secondary concern.

  • 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. 2026-05-11T02:01:47+00:00Added an answer on May 11, 2026 at 2:01 am

    The append method inserts nodes at the end of match elements. Prepend inserts nodes at the beginning.

    Example:

    $('div.favorite div a').append('<span> (favorite)</span>'); 

    The span element isn’t necessary – you can just do this:

    $('div.favorite div a').append(' (favorite)'); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to use the new jquery-ui, and all but the resizable function
Fairly new to jquery so I might be making a simple mistake but I
I have a document which uses old jQuery and I need new jQuery for
i m adding new jquery ui tabs to a tab the sample page (click
I am new jquery mobile. i want to use showPageLoadingMsg() of jquery mobile.But it
I'm making a new jQuery plugin for drawing lines on a page. The problem
I recently had a quick look at the new jQuery Sizzle, i was wondering
When writing a new jQuery plugin is there a straightforward way of checking that
Using jQuery UI 1.8rc3 combined with the new jquery.effects.fade.js code, I've been able to
I have application that brings response via Ajax and creates 5-20 new jQuery click

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.