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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:53:17+00:00 2026-05-27T16:53:17+00:00

Trying to use jquery to output a string that contains a hyphen like so:

  • 0

Trying to use jquery to output a string that contains a hyphen like so:
$("#OpsContent").html($("#OpsContent").html() + "<b>" + $(this).text() +
+ ( ( group ) ? " for <u>" + group + "</u>" : "" )
+ " to</b> " + choices + "<br />");

Unfortunately if the string “group” contains a hyphen, the output always appears as:
<b>Set Group Rank<u>NaN</u> to</b> 5

I can’t seem to get the group variable to be correctly interpretted as a string, it seems rather like it is trying to subtract the two halves of the string. I have tried using group = group.replace("-", "&#46;"); and "\-" before the line in question, but it doesn’t help. Even stranger is the fact that a line immediately after works fine:

OpsPending[ count ] = "?do=" + String($(this).attr("id"))
+ "&selection=" + choices
+ ( ( group ) ? "&group=" + group : "" );

outputs to the variable perfectly well!

A solution would be to go back and pre-process all the hyphens in the page with php, but that seems unnecessarily complicated: there should be a better way than this.

  • 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-27T16:53:18+00:00Added an answer on May 27, 2026 at 4:53 pm

    Hm, you seem to have an extra + in your string concatenation (right before the parenthesized ternary operator), which would cause the part where you are using the ternary operator to be converted from a string to a number since that extra + would be interpreted as a unary plus operator, resulting in NaN. Although that doesn’t exactly explain your symptons (i.e. it only occuring when group has a hyphen, and actually only having group appearing as NaN, not the entire ternary expression), I can’t see how your code example would work correctly without removing the extra + there

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

Sidebar

Related Questions

I am trying to use JQuery in my ASP.Net 2.0 website in this scenario:
I'm trying to use jQuery UI tabs much like a Master Page in ASP.Net.
With rails version 2.3.8 I'm trying to get HTML output like: <a href=/product/list data-role=button>Product
jsFiddle I'm trying to output images and text horizontally. The text elements use the
I am trying to use this plugin: http://docs.jquery.com/Plugins/Validation Where #user_new is the id for
I am trying to use jQuery for XML processing. One of the problem that
I'm trying to use jQuery selector to access the DOM deep inside. HTML <table>
I'm trying to use jQuery and JSON with a C# Web Service that I
I have a little problem I am trying to use MartkItUp JQuery rich text
Im trying to use Soundclouds lengthy jquery audio player to output the album artwok

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.