quinta-feira, 1 de agosto de 2013

JQUERY - Introdução


Olá pessoal.

Muitos de vocês já ouviram falar sobre JQUERY, mas o que realmente é isso?

Calma, falando de uma forma bem simples é uma biblioteca Javascript.
Que serve para simplificar e facilitar o desenvolvimento de qualquer código javascript

Como?
Vou mostrar de forma bem simples e na prática:


Javascript / HTML
<html>
<head>
<script type="text/javascript">
function onOff(){
    if(document.getElementById("lampada").style.display != "none"){
        document.getElementById("lampada").style.display = "none";
    }else{
        document.getElementById("lampada").style.display = "";
    }
}
</script>
</head>
<body>
    <div id="quarto" style="width:25px; height:25px;border:solid 1px #CCCCCC;">
        <div id="lampada" style="width:25px; height:25px; background:#000000;"></div>
    </div>
    <br/>
    <br/>
    <input type="button" onclick="onOff()" value="interruptor JS"/>
</body>
</html>



Usando JQUERY 
<html>
<head>
<script type="text/javascript">
function onOff(){
    if($("#lampada").is(":visible")){
        $("#lampada").fadeOut();
    }else{
        $("#lampada").fadeIn();
    }
}
</script>
</head>
<body>
    <div id="quarto" style="width:25px; height:25px;border:solid 1px #CCCCCC;">
        <div id="lampada" style="width:25px; height:25px; background:#000000;"></div>
    </div>
    <br/>
    <br/>
    <input type="button" onclick="onOff()" value="interruptor JQuery"/>
</body>
</html>



Exemplo na página:






Até a proxima pessoal

Nenhum comentário:

Postar um comentário