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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:30:17+00:00 2026-06-05T12:30:17+00:00

I have an h1 tag with a button and some text to it’s right

  • 0

I have an h1 tag with a button and some text to it’s right that only displays after a user action at runtime using CSS and jQuery. When the button is displayed I want to put text next to it in the h1.

The problem is that when I add the text, I lose the button.

The HTML loooks like this…

<h1>
    <input type="button" value="Open Document In New Window" id="newTabButton" class="tabButtonHidden">
</h1>

The CSS looks like this…

.tabButtonHidden {
   visibility: hidden;
}

.tabButtonVisible {
   visibility:visible;
}


#newTabButton {
    background: rgba(216, 216, 216, 6);

}

h1 {
    font: 100% Arial, Arial, Helvetica, sans-serif;
    font-size: 1.25em;
    font-weight:500;    
    background: rgba(218, 235, 245, 6);
    margin: 0px;
}

The jQuery looks like this…

if ($("#newTabButton").hasClass("tabButtonHidden")) {
   $('#newTabButton').removeClass("tabButtonHidden").addClass("tabButtonVisible");
}

$('h1').text('Now is the time for all good men...');

The last line in the jQuery writes the text where the button would normally be. If I remove that last line, change the html to include the text as follows, the jquery works perfectly, except of course that the text is static and always visible…

<h1>
    <input type="button" value="Open Document In New Window" id="newTabButton" class="tabButtonHidden">Now is the time for all good men...
</h1>

What am I missing? I need to change the text and make it and the button visible all dynamically.

Thanks for any help.

  • 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-05T12:30:20+00:00Added an answer on June 5, 2026 at 12:30 pm

    Use append() instead of text()

    http://jsfiddle.net/efortis/QSEfv/

    $('h1').append('Now is the time for all good men...');​
    

    Edit

    To prevent appending multiple times, append a span into the h1 and use text()

    See: http://jsfiddle.net/efortis/QSEfv/2/

    $('h1').append('<span>Now is the time for all good men...</span>');
    
    $('input').on('click', function () {
       $('h1 span').text('NEW...');    
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a p tag that has some styled text inside it I want
I have a jQueryUI dialog with some textboxes, plus a button. Right now, the
I have a Button that is a simple anchor tag styled with the following
I have a button class that I wrote in CSS. It essentially displays block,
I have inserted a div with some text into a parent div tag on
I have a button when i click it, some text from a textbox is
I have some ajax code in an html doc that changes the text of
I have a table, using display tag, in my application, that is using spring
I have an anchor tag <a class=next>next</a> made into a button. Sometimes, this tag
I have XML tag that has the content which is HTML document. <xml-tag> <!--

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.