Jump to content
Fórum Script Brasil
  • 0

Script expandir e ocultar


Diegobpw

Question

existe algum codigo que de pra colocar o mostra eo ocultar em 1 botao so ?

porque no caso vou precisar de 4 codigos de ocultar ficaria entranho do jeito que esta

&lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>

&lt;script type="text/javascript">

$(document).ready(function(){
                           $('#conteudo').hide();

                           $('#mostrar').click(function(event){
                           event.preventDefault();
                           $("#conteudo").show("slow");
                                                     });

                           $('#ocultar').click(function(event){
                           event.preventDefault();
                           $("#conteudo").hide("slow");
                                                     });
});
$(document).ready(function(){
                           $('#conteudo1').hide();

                           $('#mostrar1').click(function(event){
                           event.preventDefault();
                           $("#conteudo1").show("slow");
                                                     });

                           $('#ocultar1').click(function(event){
                           event.preventDefault();
                           $("#conteudo1").hide("slow");
                                                     });
});
$(document).ready(function(){
                           $('#conteudo2').hide();

                           $('#mostrar2').click(function(event){
                           event.preventDefault();
                           $("#conteudo2").show("slow");
                                                     });

                           $('#ocultar2').click(function(event){
                           event.preventDefault();
                           $("#conteudo2").hide("slow");
                                                     });
});
$(document).ready(function(){
                           $('#conteudo3').hide();

                           $('#mostrar3').click(function(event){
                           event.preventDefault();
                           $("#conteudo3").show("slow");
                                                     });

                           $('#ocultar3').click(function(event){
                           event.preventDefault();
                           $("#conteudo3").hide("slow");
                                                     });
});
<!---- 1 conteudo ---->
</script>
<body>

<p>
<a href="#" id="mostrar">Exibir conteudo </a>  |
<a href="#" id="ocultar">Ocultar conteudo</a>
</p>

<div id="conteudo" style="background-color:#fff; padding:5px; margin:0; width:350px;">
<h3>'.$user_data['hobby'].'</h3>
</div>
<!---- 2 conteudo ---->
<p>
<a href="#" id="mostrar1">Exibir conteudo</a>  |
<a href="#" id="ocultar1">Ocultar conteudo</a>
</p>

<div id="conteudo1" style="background-color:#fff; padding:5px; margin:0; width:350px;">
<h3>'.$user_data['dontlove'].'</h3>
</div>
<!---- 3 conteudo ---->
<p>
<a href="#" id="mostrar2">Exibir conteudo</a>  |
<a href="#" id="ocultar2">Ocultar conteudo</a>
</p>

<div id="conteudo2" style="background-color:#fff; padding:5px; margin:0; width:350px;">
<h3>'.$user_data['love'].'</h3>
</div>
<!---- 4 conteudo ---->
<p>
<a href="#" id="mostrar3">Exibir conteudo</a>  |
<a href="#" id="ocultar3">Ocultar conteudo</a>
</p>

<div id="conteudo3" style="background-color:#fff; padding:5px; margin:0; width:350px;">
<h3>'.$user_data['site'].'</h3>
</div>

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...