开发者

show/hide in javascript [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 10 years ago.

Hello everyone I will be explaining what i need to do and what i have 开发者_如何学JAVAso far.Ok this is what I have to do... Show code that has a div width of 300px and a background color of yellow. Do not display the div by default. Create a show link (a href). Using onclick event handler, show the div area. and this is what I have...

<!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"xml: lang = "en"lang = "en" > 
<head>
<meta http - equiv = "content-type"content = "text/html; charset=utf-8" / >
<link rel="stylesheet: href="finalpart3.css" type="text/css" />
<html>
<head>
<title>Final part 3</title>
<script language="JavaScript">
function setVisibility(id, visibility) {
document.getElementById(id).style.display = visibility;
 }
</script>

</head>
<body >
<div id="sub3"><a href="finalpart3.css"><input type="button" name="type" value='Show Layer' onclick="setVisibility('sub3', 'inline');";></div>
</body>
</html>

and here is my css file..

div {
position: absolute;
left: 100px;
top: 200px;
background-color: #FFDD00;
width: 300px;
padding: 10px;
color: black;
display: none;
 }

I know my code is wrong somewhere when you click the link it gives the code but no background color or nothing.My brain is fried at this point in time and I know it is something that is small. Can someone might point out where i need an extra code or something so that way the back ground can show up thanks. Or maybe I am ready it wrong and dont need a background color of yellow and 300px in width.


Do you see your typo here?

<link rel="stylesheet: href=...

: !== " for the closing quote.


I'm not really sure what you want to display, but other than epascarello mentioned. There other things you may want to consider. If the <div id="sub3"> is properly link to the css, your link will not be visible. Also I don't know the purpose of this <a href="finalpart3.css".

Here's my modified version of your div check it out if can be a help

<div id="sub3"><a href="finalpart3.css">link</a></div>
<input type=button name=type value='Show Layer' onclick="setVisibility('sub3', 'inline');">
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜