Find and hide text using jQuery

This, I thought, was a very simple query, but I seem to be getting lost in the find/hide code.

To simplify:

I may have something like this <h1 class="begin-page"> TEST AREA</h1>

I want to find the text "TEST AREA" and hide it.

How can I accomplish that via jquery?

Thank you.

Answers


$(function() {
    $('h1.begin-page').html($('h1.begin-page').html().replace("TEST AREA", ""));
});

$('h1:contains("TEST AREA")').html('');

jsFiddle example


$(function() {
    $('h1.begin-page')  // target the h1 element with class 'begin-page'
      .hide();          // hide it
});

copy the code-

<script>
$(document).ready(function(){
  $("#hb").click(function(){
    $("h1.begin-page").hide();
  });
});
</script>
    <p id="hb">hide</p>
    <h1 class="begin-page"> TEST AREA</h1>

or if you want you can hide and show just in a function-

<script>
$(document).ready(function(){
  $("#hb").click(function(){
    $("h1.begin-page").toggle();
  });
});
</script>
    <p id="hb">[hide/show]</p>
    <h1 class="begin-page"> TEST AREA</h1>

code without extras-

      $(function(){
        $("h1.begin-page") // find the text
.hide(); // hide it
      });

from - http://www.w3schools.com/jquery/jquery_hide_show.asp


Need Your Help

How to scroll to top of page when accordion is clicked?

javascript jquery accordion

I have the following jQuery, its working fine. What I need is when the accordion is clicked to take the user to the top of page of the active accordion.

Detect what page you are on javascript?

javascript html

Is there any way to detect what page you are on in javscript?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.