JQUERY

FORMAS DE DECLARAR EL JQUERY

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JQuery Tutorial</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js"></script>
</head>
<body>


     <div id="codigo"> Codigo Mentor</div>
          <script text="text/javascript">


              // Primera forma de declarar
             $(document).on("ready", function () {
             });


             // Segunda forma de declarar
             $(document).ready(function () {
             });


             // Tercera forma de declarar
            $(function () {
            });

        </script>


</body>
</html>




<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JQuery Tutorial</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js"></script>
</head>
<body>

    <div id="codigo"> Codigo Mentor</div>


    <script text="text/javascript">


        // Segunda forma de declarar

        $(document).ready(function () {
            $("#codigo").hide(3000).show(1000);
        });
    </script>

</body>

</html>


MANJEO DEL SELECTOR : ID


<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JQuery Tutorial</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js"></script>
</head>
<body>

    <button>Aceptar</button>

    <div id="texto1">Texto 1</div>
    <div id="texto2">Texto 2</div>
    <div id="texto3">Texto 3</div>

    <script text="text/javascript">


        // Segunda forma de declarar

        $(document).ready(function () {
            $("button").click(function () {
                // Desaparece el texto 2 al dar click en el boton aceptar
                //$("#texto2").hide();
                // Desaparece todo al dar click en el boton aceptar
                $("*").hide();
            });
        });
    </script>
</body>
</html>



<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JQuery Tutorial</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js"></script>
</head>
<body>

    <input type="text" id="espacio" />

    <input type="submit" id="enviar" value="Aceptar" />

    <script text="text/javascript">


        // Segunda forma de declarar
        $(document).ready(function () {
            $("#enviar").click(function () {
                var x = $("#espacio").val();
                alert(x);
            });
        });
    </script>
</body>
</html>


USO DEL SELECTOT : THIS


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $("p.intro").hide();
    });
});
</script>
</head>
<body>

<h2 class="intro">This is a heading</h2>

<p class="intro">This is a paragraph.</p>
<p>This is another paragraph.</p>

<button>Click me</button>

</body>
</html>


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $(this).hide();
    });
});
</script>
</head>
<body>

<h2>This is a heading</h2>

<p>This is a paragraph.</p>
<p>This is another paragraph.</p>

<button>Click me</button>

</body>
</html>



<!DOCTYPE html>

<html>

<head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $("*").hide();
    });
});
</script>
</head>
<body>

<h2>This is a heading</h2>

<p>This is a paragraph.</p>
<p>This is another paragraph.</p>

<button>Click me</button>

</body>
</html>


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $(".test").hide();
    });
});
</script>
</head>
<body>

<h2 class="test">This is a heading</h2>

<p class="test">This is a paragraph.</p>
<p>This is another paragraph.</p>

<button>Click me</button>

</body>
</html>


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $("*").hide();
    });
});
</script>
</head>
<body>

<h2>This is a heading</h2>

<p>This is a paragraph.</p>
<p>This is another paragraph.</p>

<button>Click me</button>

</body>
</html>



FUENTE : http://codigomentor.com/main_page/

Comentarios

Entradas populares de este blog

Para que sirve la N en SQL Server

MYSQL : CURSORES

SSIS- Package con origen de datos Excel dinámicos