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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:42:12+00:00 2026-06-01T18:42:12+00:00

Sorry for dumb question but I can’t figure it out (beginner) I have a

  • 0

Sorry for dumb question but I can’t figure it out (beginner)

I have a UL-list with items like:

<div id="some_list"> 
<li ><a href="#">Hardware &ndash; HP Proliant DL145G2 AAA</a> 

How can I change OnClick the AAA to BBB?

I assume that the function should call $(document).ready, but I have no idea what should I do in function change_list.

<script type="text/javascript">
function change_list(aaa){
...
}
$(document).ready(function () {
    $('#some_list li a').click(change_list);
}); 
  • 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-06-01T18:42:14+00:00Added an answer on June 1, 2026 at 6:42 pm

    This is a good use for the function argument version of .text():

    $('#some_list li a').click(function() {
        $(this).text(function(index, text) {
             return text.replace('AAA', 'BBB');
        });
    });
    

    The function argument versions of many jQuery functions are particularly appropriate for “read-modify-write” operations.

    They avoid the need to write separate code to read the value, modify it, and then write the value back into the DOM.

    The alternative would have looked like this:

    $('#some_list li a').click(function() {
        var oldText = $(this).text();
        var newText = oldText.replace('AAA', 'BBB');
        $(this).text(newText);
    });
    

    Note how this now calls .text() twice – once to retrieve the value, and then again to write the new value.

    As it happens in this case the savings aren’t great, but the method is particularly powerful when you want to modify things like attributes, or CSS values, etc, as it avoids a lot of code repetition.

    The other advantage of the function argument method is that it allows you to separate logic from DOM manipulation. You can write trivial modification functions that only care about modifying strings, and leave jQuery to handle the DOM manipulation.

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

Sidebar

Related Questions

I'm sorry if this will sound like a dumb question but I just can't
Ok sorry this might seem like a dumb question but I cannot figure this
Sorry for the dumb question, but I'am not able to figure out my typo:
Sorry if this seems like a dumb question but I am just learning bash
Sorry for my dumb question, but how can I get the size of a
Sorry for my dumb question, but how can I upgrade shared ownership to upgrade?
Hey, sorry for the dumb question, but how can I upgrade iOS SDK to
Sorry for the dumb question, but I'm working with Qt and C++ for the
Sorry if this is a dumb question, but it is possible to store, and
Sorry if it is a dumb question, but the issue is quite straight forward.

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.