0

よくわかりません。JavaScript の例で CSS を使用して 3 つのボタンを非表示にしようとしましたが、何も起こりませんでした。li.two と li.three が非表示にならないのはなぜですか? ボタンをクリックするまで、li.two と li.three が表示されないようにしたいと考えています。(Yahoo は Google をクリックしたときにのみ表示され、Facebook は Yahoo をクリックしたときにのみ表示されます) コードは次のとおりです。

<html>
<head>
<script type="text/javascript">
function show_prompt()
{
var name=prompt("Your Name");
if (name!=null && name!="")
  {
  alert("Thanks for clicking " + name + "!");
  window.open("http://www.google.com/};
}
</script>
<script type="text/javascript">
function show_alert()
{
alert("Thanks for clicking me!");
window.open("http://www.yahoo.com/");
}
</script>
<script type="text/javascript">
function show_alert1()
{
alert("Have fun on Facebook!");
window.open("http://www.facebook.com/");
}
</script>
<script type="css/text">
li.two, li.three {display:none};
</script>
</head>
<body>
<ul>
<li class="one"><input type="button" onclick="show_prompt();showNext('Yahoo')" value="Google" />
<li class="two"><input type="button" id="Yahoo" onclick="show_alert();showNext('Facebook')" value="Yahoo" />
<li class="three"><input type="button" id="Facebook" onclick="show_alert1()"value="Facebook" />
</ul>
</body>
</html>
4

3 に答える 3

2

に終了タグがありません<li>

<li class="one"><input type="button" onclick="show_prompt();showNext('Yahoo')" value="Google" /></li>
<li class="two"><input type="button" id="Yahoo" onclick="show_alert();showNext('Facebook')" value="Yahoo" /></li>
<li class="three"><input type="button" id="Facebook" onclick="show_alert1()"value="Facebook" /></li>

CSS が間違っています;{}

li.two, li.three {display:none;}

そしてあなたのcssは<script>タグにあり、中にある必要があります:

<style type="text/css">li.two, li.three {display:none;}</style>

于 2012-04-12T12:17:17.197 に答える
1

これを使用する必要があります

<li class="one"><input type="button" onclick="show_prompt();showNext('Yahoo')" value="Google" />
<li class="two"><input type="hidden" type="button" id="Yahoo" onclick="show_alert();showNext('Facebook')" value="Yahoo" />
<li class="three"><input type="hidden" type="button" id="Facebook" onclick="show_alert1()"value="Facebook" />
于 2012-04-12T12:39:48.853 に答える