をホープ、次のコード(およびcodepen例)私はあなたが何をしようとして設定したいどのようになります。
HTML:
<ul>
<li>
<a href="dogs.html">
Dogs
</a>
</li>
<!-- you want to hide the LI, because if you hide the <a>, then
there will be an empty <li> that you'll need to deal with in
the layout of your page/screen reader users may end up
wondering why there is an empty list item
-->
<li id="cats_item" class="display-none">
<a href="cats.html">
Cats
</a>
</li>
</ul>
<p id="reveal_message">
Reveal a link to cats via the following button:
<!--
Use a button here since you're triggering an action
on the page, and not actually linking anywhere.
-->
<button type="button" id="reveal_button">
Reveal Cats
</button>
</p>
CSS
/* this is all you need to hide any element */
.display-none {
display: none;
}
jQueryの
$('#reveal_button').on('click', function() {
// reveal the LI that contains the cats link
$('#cats_item').show();
/* hide the reveal message, since cats is shown,
this no longer has any usefulness (or change the message
and action to a 'toggle' to show/hide the cat link
*/
$('#reveal_message').hide();
/*
move keyboard focus to the cats link, otherwise
keyboard users would have to traverse back up the
DOM to get to the newly revealed link
*/
$('#cats_item a').focus();
});
ここでは、ボタンをクリックしたときに、猫のリンクを明らかにcodepenです: http://codepen.io/scottohara/pen/VbYyGr
どのようにデフォルトで非表示にしますか?デフォルトでは隠されていた_li_やアンカー_a_があるかもしれません。 –
いくつかのCSSを使用しました。リンクを非表示にするために使用されたcsコードを追加しました –
私たちにCSSを表示してください。 –