Solved

hide all div's that start with a certain word

Posted on 2011-03-10
2
680 Views
Last Modified: 2012-05-11
Hi,

I have a few divs

<div id="help_a">a</div>
<div id="help_b">b</div>
<div id="help_c">c</div>
<div id="help_d">d</div>

When the page loads I have a function that is supposed to hide all of them (but doesn't work):

$(function() {
  $("div[id^='help_']").each(function() {
      this.id.hide();
  });
});

What am I doing wrong?

Thanks!
0
Comment
Question by:jagku
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 35096183
replace
this.id.hide();

Open in new window

by
$(this).hide()

Open in new window


work for me :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script language="javascript" src="http://code.jquery.com/jquery-1.5.1.min.js"></script>
<script language="javascript">

	$(document).ready(function() {
	  $("div[id^='help_']").each(function() {
	      $(this).hide();
	  });
  });

</script>
<body>
<div id="help_a">a</div>
<div id="help_b">b</div>
<div id="help_c">c</div>
<div id="help_d">d</div>
<div id="ahelp_d">not me</div>
</body>
</html>

Open in new window

0
 

Author Closing Comment

by:jagku
ID: 35096276
doh!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JQuery Syntax... 4 50
why JSON Array data not binding on Model ASP.NET ? 1 30
Getting selected value using Jquery 3 23
Building JSON/JQuery Results Display 11 28
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question