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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:20:43+00:00 2026-06-07T10:20:43+00:00

I have a jQuery function I am calling with the below code. The function

  • 0

I have a jQuery function I am calling with the below code. The function searches for the words shown in the “words:” area in the “QAList” and then makes just those words bold. This is working fine with this code and the words “Demo” and “or” are made bold.

    $("[id$=QAList]").wrapInTag({
      words: ['Demo User', 'or'],
      tag: '<selected>'
    });

I am now trying to pass the “words:” list in from a label or textbox but for some reason I cannot get it to pass the correct information, and I am not 100% sure to see what it is actually passing.

This is how I changed the code to pull from the lblSelectedQA label:

    $("[id$=QAList]").wrapInTag({
      words: [$("[id$=lblSelectedQA]").html()],
      tag: '<selected>'
    });

I even tried it from a textbox in case the label was not working for some reason:

    $("[id$=QAList]").wrapInTag({
      words: [$("[id$=lblSelectedQA]").val()],
      tag: '<selected>'
    });

I am getting what I need from the label and the textbox if I put them in an alert, they return:

‘Demo User’, ‘or’

Do I have incorrect syntax after the “words:” now that I am trying to pass the value from somewhere else?

Thanks!

**Edit in response to iurisilvio’s answer below

In response to your answer I changed my code a little bit both in what is populating the 'Demo User', 'or' text to get rid of the single quotes and extra spaces. It now looks like this: Demo User,or and works fine with single results.

I then tried adding the .split(“,”) which works for one of the values in the array if I add the index [0] or [1], but will not stand alone for all the array items.

Utkanos shows basically the same thing, just adding a way to also get rid of the spaces and single quotes which I no longer need to do.

This is my code now which works for a single result:

    $("[id$=QAList]").wrapInTag({
      words: [$("[id$=lblSelectedQA]").html().split(",")],
      tag: '<selected>'
    });

But when it returns multiple results it won’t work unless I add the index, but then will only work for the index that I hard code… not an option since I don’t know how many will be in this array.

    $("[id$=QAList]").wrapInTag({
      words: [$("[id$=lblSelectedQA]").html().split(",")[0]],
      tag: '<selected>'
    });

or

    $("[id$=QAList]").wrapInTag({
      words: [$("[id$=lblSelectedQA]").html().split(",")[1]],
      tag: '<selected>'
    });

Is there a way for me to get it to take all the array items without having to loop through them?

Thanks!

**Edit for solution:

I needed to drop the brackets around what I was just adding. I figured that out and came back and Utkanos had just posted the same thing 🙂

Working code:

    $("[id$=QAList]").wrapInTag({
      words: $("[id$=lblSelectedQA]").html().split(","),
      tag: '<selected>'
    });

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-06-07T10:20:45+00:00Added an answer on June 7, 2026 at 10:20 am

    The words parameter should be an array. The string 'Demo User', 'or' looks like the print-out from an array that contains those values, but is ultimately a string, not an array.

    In other words, you’re passing a string that looks a bit like an array, not an actual array.

    Assuming the string you’re retrieving from the element is, as you say, 'Demo User', 'or', you need to split that into an array by splitting on the delimiter – in your case, the comma and space. You’ll also need to remove the ' around the various tokens.

    $("[id$=QAList]").wrapInTag({
        words: $("[id$=lblSelectedQA]").val().replace(/'/g, '').split(, ?/),
        tag: '<selected>'
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP script that I'm calling with the .post() function in jQuery.
I have the below jquery function $(function(){ $(select#rooms).change(function(){ $.getJSON(/admin/select.php,{id: $(this).val(), ajax: 'true'}, function(j){ var
I have below function for my jQuery Datepicker. $(document).ready(function() { $(.txtDate).datepicker({ showOn: 'button', buttonImage:
I have some weird problems with jQuery ajax. I am calling jQuery ajax function
I have a jQuery function already to perform the task I need but is
Here's the story... I have a jQuery function that does something, this function is
I have the following jquery function for filtering the contents of a listbox on
I have a jQuery setInterval function named timerIncrement that times out (stops incrementing the
I have the following jquery function > <script type=text/javascript> > > $(document).ready(function() { >
I have the following jQuery function: $(function(){ if ($(.menu li).hasClass(active)) { $(.active).css(margin-top, 6px); }

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.