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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:54:44+00:00 2026-05-18T04:54:44+00:00

I am trying to find all <h2> tags the split them and join them

  • 0

I am trying to find all <h2> tags the split them and join them with <a href=''></a> around them. I am so close but stuck.

<script type="application/javascript">
$(document).ready(function() {


// finds all h2's within wrapper div grabs the text splits at ? and applies a links around each one
var al = $('#wrapper').find('h2').text().split("?").join("?</a><br /> <a  href='#'>");

// Add all the split h2's from the variable above al to a div called .text
$('.text').html('<ul>' + al + '</ul>');


});      
</script>

This is my output from alert(al):

Appropriate Media – Why radio?</a><br /> <a  href='#'>Can someone come and speak at my church?</a><br /> <a  href='#'>Do you distribute radios?</a><br /> <a  href='#'>Do you partner with other organisations?</a><br /> <a  href='#'>How is Feba funded?</a><br /> <a  href='#'>What are your programmes about?</a><br /> <a  href='#'>What denomination does Feba belong to?</a><br /> <a  href='#'>What happened to the Chrysolite?</a><br /> <a  href='#'>What is airtime?</a><br /> <a  href='#'>What is Feba's Statement of Faith?</a><br /> <a  href='#'>Where are the programmes made?</a><br /> <a  href='#'>Where can I find out about the languages & countries you broadcast in?</a><br /> <a  href='#'>Where does the name Feba come from?</a><br /> <a  href='#'>Who do you broadcast to?</a><br /> <a  href='#'>Why do you broadcast on short wave?</a><br /> <a  href='#'> 

Ok so at the moment I am able to split them at the ? because each question end with a ?, but my issue is this misses out the first question.

So my solution would be to split them at the <h2> tags is this possible or is there a better option i have tried so many?

  • 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-18T04:54:45+00:00Added an answer on May 18, 2026 at 4:54 am

    Brilliant this worked thanks a lot. I am just trying to understand the code so i can utilize it in the future. I am pretty new to jquery and want to learn 😉

    Here is the webpage i am working on and full code so you can see the result. You might see an better way off doing it.

    http://www.giveradio.org.uk/faqs

    <script type="application/javascript">
        $(document).ready(function() {
    
        var al = $('.text');
    
        $('h2').each(function(){
            $('<a>', {
                text: $(this).text(),
                href: '#'
            }).wrap('<li>').parent().appendTo(al);
        });
    
        $('.text a').click(function(e) {
    
        e.preventDefault(); 
    
        // Removes h2 class jump which is added below
        $('h2').removeClass('jump');
    
        // Grabs the text from this a link that has been clicked
        var alink = $(this).text(); 
    
        // filters through all h2's and finds a match off text above and add class jump
        $('h2:contains("' + alink +'")').addClass("jump");
    
        // scrollto the h2 with the class jump
        $('html,body').animate({scrollTop: $("h2.jump").offset().top},'fast');
    
        return false;
    
        }); 
    
    
        });                  
        </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to find all the anchor tags and appending the href value with
Im trying to do a regex where I can find all html tags, but
I'm trying to find all the hash tags in a string. The hashtags are
I'm trying to find all occurances of all the tags, say, [[tag1]] [[tag2]] [[tag3]]
Im trying to find all p tags with inline style attrs style=text-align:center; that contain
I'm trying to find about ALL the possible options that I can set in
I'm trying to use XPath to find all elements that have an element in
I'm trying to use VDMEnumProcessWOW to find all 16 bit host processes on Vista.
In Java, I'm trying to log into an FTP server and find all the
In Ruby, I'm trying to do the following. def self.stats(since) return Events.find(:all, :select =>

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.