[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

visibilty of a div

Posted on 2009-02-19
2
Medium Priority
?
301 Views
Last Modified: 2012-05-06
i have a link and i am using jquery to show a div when the link is clicked.
it doesn't open. pl suggest.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
  <script>
	$("#lin").click(function() {
    alert("open");
    $('#con').css('visibility','visible') ;
	});
  </script>
  <style>
	#con {
		visibility:hidden;
		border:1px solid green;
	}
  </style>
 </HEAD>
 <BODY>
  <a href="#" id="lin">open con</a>
  <div id="con">
	hello world
  </div>
 </BODY>
</HTML>

Open in new window

0
Comment
Question by:vidhubala
2 Comments
 
LVL 43

Accepted Solution

by:
David S. earned 2000 total points
ID: 23687578
Your script was trying to access #lin before it was loaded. Use jQuery's ready function: http://docs.jquery.com/Events/ready#fn
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("#lin").click(function() {
    alert("open");
    $('#con').css('visibility','visible');
  });
});
</script>
<style type="text/css">
#con {
        visibility:hidden;
        border:1px solid green;
}
</style>
</head>
 <body>
  <a href="#" id="lin">open con</a>
  <div id="con">
        hello world
  </div>
 </body>
</html>

Open in new window

0
 

Author Closing Comment

by:vidhubala
ID: 31549044
cool. thanks.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
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…
Suggested Courses

864 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