JavaScript Show/Hide Помогите разобраться!

big boy
На сайте с 18.11.2006
Offline
307
1201

Хочу использовать скрипт. Вроде простенький, но так как мои знания java стремятся к нулю, приходится обращаться за помощью.

Скрипт показывает и прячет <DIV> по нажатии на ссылку. По умолчанию содержание <DIV> скрыто, а я бы хотел наоборот, чтобы при загрузке оно отображалось, а при нажатии ссылки пряталось.

Привожу код.

<script language="javascript" type="text/javascript">
function showHide(shID) {
if (document.getElementById(shID)) {
if (document.getElementById(shID+'-show').style.display != 'none') {
document.getElementById(shID+'-show').style.display = 'none';
document.getElementById(shID).style.display = 'block';
}
else {
document.getElementById(shID+'-show').style.display = 'inline';
document.getElementById(shID).style.display = 'none';
}
}
}
</script>
<style type="text/css">

#wrap {

font: 1.3em/1.3 Arial, Helvetica, sans-serif;
margin: 0 auto;
padding: 1em;
background-color: #fff; }


/* This CSS is used for the Show/Hide functionality. */
.more {
position: fixed;
top: 5px;
left: 5px;
display: none; }
a.showLink, a.hideLink {
text-decoration: none;
color: #36f;
padding-left: 8px;
background: transparent url(down.gif) no-repeat left; }
a.hideLink {
background: transparent url(up.gif) no-repeat left; }
a.showLink:hover, a.hideLink:hover {
border-bottom: 1px dotted #36f; }
</style>

<div id="wrap">
<a href="#" id="example-show" class="showLink" onclick="showHide('example');return false;">See more.</a>

<div id="example" class="more">
<a href="#" id="example-hide" class="hideLink" onclick="showHide('example');return false;">Hide this content.</a>
<BR>СОДЕРЖАНИЕ БЛОКА

</div>
</div>

Скрипт взят отсюда - http://www.cssnewbie.com/showhide-content-css-javascript/

✔ Google spam update убил сайты? Что делать - https://webmasta.ru/blog/google-october-2022-spam-brain-update
vlasoff
На сайте с 31.08.2007
Offline
101
#1
big boy:
а я бы хотел наоборот, чтобы при загрузке оно отображалось, а при нажатии ссылки пряталось.

.more {    

position: fixed;
top: 5px;
left: 5px;
display: block; }

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий