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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:10:01+00:00 2026-05-24T08:10:01+00:00

I need to replace the dash in a title on by site with a

  • 0

I need to replace the dash in a title on by site with a span tag and line break to break to title over two lines.
Unfortunately I don’t have access to do this in the PHP 🙁

The below statement seems to do this. Although with bugs as it’s making this change to the character throughout the page.

document.body.innerHTML = document.body.innerHTML.replace(/\u2013/g, "</span><br /><span>");

The jQuery solution I tried below, works but sometimes the element would have a visibility hidden on the element!

$("#events h3 a").each(function() {
  $(this).html($(this).html().replace(/\u2013/g,"</span><br /><span>"));
});

Ideally I would like to use the pure JavaScript version above but need help navigating to the Events Link.

#events h3 a

Thanks anybody who can help, I have hunted for a solution everywhere.

This is an example of the page structure. And explains why the span close and start are back to front in the code excerpt. This is so each half can be styled when on separate lines.

<ul id="events">
    <li>
        <h3>
            <a href="http://example.com">
                <span>First Events Title - On Every Sunday</span>
            </a>
        </h3>
    </li>
    <li>
        <h3>
            <a href="http://example.com">
                <span>Second Events Title - On Every Monday</span>
            </a>
        </h3>
  </li>
</ul>
  • 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-24T08:10:01+00:00Added an answer on May 24, 2026 at 8:10 am

    It seems so simple, is this a trick question? If it as simple as i thought try this.

    $(function () {
        $("#events h3 a").each(function () {
            $(this).html($(this).html().split(" - ").join("</span><br/><span>"));
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string. I need to replace all instances of a given array
I have a word : [lesserthen] , that I need to replace with <
I have a string. In this string i need replace all special characters (0-31
I have a string like hello /world today/ I need to replace /world today/
I have a replacement problem in VB.NET: I need to replace the character: result
I have a large solution with a lot of lines that I need to
i have a input tag which is non editable, but some times i need
I often have text in columns and need to replace some things without clobbering
I have a table that contains form elements that I need to replace if
I have some large csv files (1.5gb each) where I need to replace specific

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.