123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 |
- $(function() {
- $(".open-code").each(function(i) {
- $(this).attr('id', "open" + (i + 1));
- });
- $(".hide-code").each(function(i) {
- $(this).attr('id', "hide" + (i + 1));
- });
-
- $( ".select_hide" ).change(function() {
- var id = $(this).children(":selected").attr("id");
- $(".hide-code").hide();
- var id_element2 = id.replace("open", "");
- $("#hide"+id_element2).show();
- });
-
- });
- $(function() {
- $(".odd-li").click(function() {
- $("#parraPrim > p, #listaPrim > li").css("background-color", "transparent");
- $("#listaPrim > li:odd").css( "background-color", "red");
- });
- $(".odd-p").click(function() {
- $("#parraPrim > p, #listaPrim > li").css("background-color", "transparent");
- $("#parraPrim > p:odd").css( "background-color", "red");
- });
- $(".even-li").click(function() {
- $("#parraPrim > p, #listaPrim > li").css("background-color", "transparent");
- $("#listaPrim > li:even").css( "background-color", "red");
- });
- $(".even-p").click(function() {
- $("#parraPrim > p, #listaPrim > li").css("background-color", "transparent");
- $("#parraPrim > p:even").css( "background-color", "red");
- });
- $(".clear-oddeven").click(function() {
- $("#parraPrim > p, #listaPrim > li").css("background-color", "transparent");
- });
- });
- $(function() {
- $(".first-li").click(function() {
- $(".seleccion").css("background-color", "transparent");
- $(".seleccion:first").css( "background-color", "red");
- });
- $(".eq-li").click(function() {
- var valor = $("#valorSelect").val();
- $(".seleccion").css("background-color", "transparent");
- $(".seleccion:eq("+valor+")").css( "background-color", "red");
- });
- $(".gt-li").click(function() {
- var valor = $("#valorSelect").val();
- $(".seleccion").css("background-color", "transparent");
- $(".seleccion:gt("+valor+")").css( "background-color", "red");
- });
- $(".lt-li").click(function() {
- var valor = $("#valorSelect").val();
- $(".seleccion").css("background-color", "transparent");
- $(".seleccion:lt("+valor+")").css( "background-color", "red");
- });
- $(".slice-li").click(function() {
- var valor = $("#valorSelect").val();
- var valor2 = $("#valorSelect2").val();
- $(".seleccion").css("background-color", "transparent");
- $(".seleccion").slice(valor, valor2).css( "background-color", "red");
- });
- $(".clear-li").click(function() {
- $(".seleccion").css("background-color", "transparent");
- });
- });
- $(function() {
- $(".tell-hidden").click(function() {
- var num = $(".seleccion2:hidden");
- alert("Los elementos escondidos son " + num.length);
- });
- $(".show-hidden").click(function() {
- $(".seleccion2:hidden").show();
- });
- $(".all-hidden").click(function() {
- $(".seleccion2").hide();
- });
- $(".clickVisibly").click(function() {
- $("li").each(function() {
- if ($(this).css("visibility") === "hidden") {
- $(this).css("visibility", "visible");
- }
- });
- });
- $(".clear-li2").click(function() {
- $(".seleccion2").show();
- $(".element-hidden").hide();
- $(".element-invisible").css("visibility", "hidden");
- });
- });
- $(function() {
- $(".div-has").click(function() {
- $(".padre-div").has("li").css("background", "red");
- });
- $(".not-has").click(function() {
- $( "#list-father li" ).not( "#has-father").css("background", "red");;
- });
- $(".clear-li3").click(function() {
- $("li").css("background-color", "transparent");
- $(".padre-div").css("background-color", "transparent");
- });
- });
- $(function() {
- $(".shmi-son").click(function() {
- clear4();
- $( ".shmi-child" ).children("img").css( "border", "3px solid red" );
- });
- $(".vader-children").click(function() {
- clear4();
- $( ".vader-child").children("img").css( "border", "3px solid red" );
- });
- $(".leia-son").click(function() {
- clear4();
- $( ".leia-child>img" ).css( "border", "3px solid red" );
- });
- $(".shmi-descendant").click(function() {
- clear4();
- $( ".shmi-child" ).find("img").css( "border", "3px solid red" );
- });
- $(".vader-descendant").click(function() {
- clear4();
- $( ".vader-child img" ).css( "border", "3px solid red" );
- });
- $(".luke-sibling").click(function() {
- clear4();
- $( "#luke" ).next().children("img").css( "border", "3px solid red" );
- });
- $(".leia-sibling").click(function() {
- clear4();
- $( "#leia" ).prev().children("img").css( "border", "3px solid red" );
- });
- $(".kylo-mother").click(function() {
- clear4();
- $( "#kylo" ).parent().children("img").css( "border", "3px solid red" );
- });
- $(".kylo-ancestor").click(clear4,function() {
- clear4();
- $( "#kylo img" ).parentsUntil("#star-wars").find( ".ancestor" ).css( "border", "3px solid red" );
- });
- $(".clear-li4").click(clear4);
- });
- function clear4() {
- $("#star-wars img").css("border", "3px transparent");
- $("#star-wars div").css("border", "3px transparent");
- }
- $(function() {
- $(".input-type").click(function() {
- var allInputs = $( ":input");
- $( "#form-result" ).text( "Encontrados " + allInputs.length + " inputs." );
- });
- $(".pass-type").click(function() {
- var input = $( "input:password" ).css({
- background: "yellow",
- border: "3px red solid"
- });
- $( "#form-result" )
- .text( "Hay " + input.length + " input de tipo 'password'." )
- .css( "color", "red" );
- });
- $(".reset-type").click(function() {
- var input = $( "input:reset" ).css({
- background: "yellow",
- border: "3px red solid"
- });
- $( "#form-result" )
- .text( "Hay " + input.length + " input de tipo 'reset'." )
- .css( "color", "red" );
- });
- $(".radio-type").click(function() {
- var input = $( "input:radio" ).css({
- background: "yellow",
- border: "3px red solid"
- });
- $( "#form-result" )
- .text( "Hay " + input.length + " input de tipo 'radiobutton'." )
- .css( "color", "red" );
- });
- $(".submit-type").click(function() {
- var input = $( "input:submit" ).css({
- background: "yellow",
- border: "3px red solid"
- });
- $( "#form-result" )
- .text( "Hay " + input.length + " input de tipo 'submit'." )
- .css( "color", "red" );
- });
- $(".text-type").click(function() {
- var input = $( "input:text" ).css({
- background: "yellow",
- border: "3px red solid"
- });
- $( "#form-result" )
- .text( "Hay " + input.length + " input de tipo 'text'." )
- .css( "color", "red" );
- });
- $(".checkbox-type").click(function() {
- var input = $( "input:checkbox" ).css({
- background: "yellow",
- border: "3px red solid"
- });
- $( "#form-result" )
- .text( "Hay " + input.length + " input de tipo 'checkbox'." )
- .css( "color", "red" );
- });
- $(".button-type").click(function() {
- var input = $( "form input:button" ).css({
- background: "yellow",
- border: "3px red solid"
- });
- $( "#form-result" )
- .text( "Hay " + input.length + " input de tipo 'button'." )
- .css( "color", "red" );
- });
- $(".select-type").click(function() {
- var input = $( "#form-prueba option:selected" );
- $( "#form-result" )
- .text( "Has elegido la opción " + input.text())
- .css( "color", "red" );
- });
- $(".clear-form").click(function() {
- $("#form-prueba input").css({
- background: "#e7e7e7",
- color: "black",
- border: "black"
- });
- });
- });
- $(function() {
- $("#myListFil").click(function() {
- $( "#myList li" ).css( "background-color", "transparent" );
- $( "#myList li" ).filter( ":even" ).css( "background-color", "red" );
- });
-
- $("#myListFil2").click(function() {
- $( "#myList li" ).css( "background-color", "transparent" );
- $( "#myList li" ).filter(function() {
- return $( "strong", this ).length === 1;
- })
- .css( "background-color", "red" );
- });
-
- $("#myListFil3").click(function() {
- $( "#myList li" ).css( "background-color", "transparent" );
- $( "#myList li" ).filter(function() {
- return $( "strong", this ).length === 2;
- })
- .css( "background-color", "red" );
- });
-
- $("#myListClear").click(function() {
- $( "#myList li" ).css( "background-color", "transparent" );
- })
- });
|