l00ker Posted April 28, 2015 at 01:31 PM Report Share #582045 Posted April 28, 2015 at 01:31 PM (edited) boas pessoas tenho uma pequena dúvidas.. gostava que ao carregar no 1 que é um link abrisse ou mostrasse uma div é possivel? tenho o seguinte código: <html> <li><a href="#">1</li></a> <li><a href="#">2</a></li> <li><a href="#">3</a></li> </html> Edited April 28, 2015 at 01:45 PM by apocsantos geshi Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted April 28, 2015 at 01:43 PM Report Share #582048 Posted April 28, 2015 at 01:43 PM sabes javascript ? IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
l00ker Posted April 28, 2015 at 03:42 PM Author Report Share #582062 Posted April 28, 2015 at 03:42 PM (edited) Não me funciona sempre este código, já o analisei e não encontro nenhum erro <html> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> <style type= "text/css "> div{ border: solid 2px; width: 500px; height: 300px; } </style> <script> function mostrar_abas(obj) { document.getElementById('div_aba1').style.display="none"; document.getElementById('div_aba2').style.display="none"; document.getElementById('div_aba3').style.display="none"; switch (obj.id) { case 'mostra_aba1': document.getElementById('div_aba1').style.display="block"; break case 'mostra_aba2': document.getElementById('div_aba2').style.display="block"; break case 'mostra_aba3': document.getElementById('div_aba3').style.display="block"; break } } </script> <li><a style="cursor: pointer; cursor: hand;" onclick="mostrar_abas(this);" id="mostra_aba1" >aba1</a></li> <li><a style="cursor: pointer; cursor: hand;" onclick="mostrar_abas(this);" id="mostra_aba2" >aba2</a></li> <li><a style="cursor: pointer; cursor: hand;" onclick="mostrar_abas(this);" id="mostra_aba3" >aba3</a></li> <p></p> <!-- abas --> <div id="div_aba1" style="display:none;"> Conteúdo da aba 1 </div> <div id="div_aba2" style="display:none;"> Conteúdo da aba 2 </div> <div id="div_aba3" style="display:none;"> Conteúdo da aba 3 </div> </html> Edited April 28, 2015 at 05:37 PM by apocsantos geshi Link to comment Share on other sites More sharing options...
help Posted May 3, 2015 at 03:46 PM Report Share #582374 Posted May 3, 2015 at 03:46 PM (edited) Pode usar jQuery <script src="http://code.jquery.com/jquery-latest.min.js"></script> <script> $(document).ready(function() { $('.l').click(function(){ $('.d').hide(); $('#'+$(this).text()).show(); }); }); </script> <style> .d{display:none;} </style> <ul> <li><a href="#" class="l">1</a></li> <li><a href="#" class="l">2</a></li> <li><a href="#" class="l">3</a></li> </ul> <div id="1" class="d">1</div> <div id="2" class="d">2</div> <div id="3" class="d">3</div> Edited May 3, 2015 at 05:39 PM by apocsantos geshi Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now