Título: problema llamar funcion jquery con php
Publicado por: soru13 en 22 Enero 2012, 18:51 pm
hola, tengo el siguiente código <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <head><title> Jquery Lights Off Experiment </title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $("#the_lights").fadeTo(1, 0); $(".turnon").hide(); $(".turnoff").click(function () { $("#the_lights").css({ 'display': 'block' }); $("#the_lights").fadeTo("slow", 0.8); $(".turnon").show(); $(".turnoff").hide(); }); $(".turnon").click(function () { $("the_lights").css({ 'display': 'block' }); $("#the_lights").fadeTo("slow", 0); $(".turnoff").show(); $(".turnon").hide(); }); }); </script> <style type="text/css"> html { width: 100%; height: 100%; margin: 0px; } #the_lights { background-color: #000; height: 100%; width: 100%; position: absolute; top: 0; left: 0; display: none; z-index: 10; } .standout { padding: 5px; background-color: white; position: relative; z-index: 20; width:640px; height:390px; margin: 0px auto; } .button-standout { background-color: White; position: relative; z-index: 20; margin: 0px auto; width: 100px; height: 20px; } button { width: 100px; height: 20px; } </style> </head>
<body"> <div> <p> The Jquery Lights Off effect. This is especially useful when you are watching a video on a website. If you switch off the lights, the surroundings of the video will go dark and it will seem like you are watching a movie in a theater.</p> </div> <div id="a" class="button-standout"> <button id="turnoff" class="turnoff" name="turnofflights"> Lights Off</button>
<button id="turnon" class="turnon" name="turnonlights"> Lights On</button></div> <div id="standout" class="standout" align="center"> CONTENIDO </div> <div id="the_lights"> </div> </body>
</html>
el caso es que funciona si le doy al botón, pero yo necesito que se ejecute cuando haga un echo en php. Llevo 2 horas mirando en internet y probando, pero no consigo nada, ¿alguien me podria ayudar?. Gracias
Título: Re: problema llamar funcion jquery con php
Publicado por: #!drvy en 22 Enero 2012, 19:30 pm
Hola, javascriptfunction apagarLuz(){ $("#the_lights").css({ 'display': 'block' }); $("#the_lights").fadeTo("slow", 0.8); $(".turnon").show(); $(".turnoff").hide(); } function encenderLuz(){ $("the_lights").css({ 'display': 'block' }); $("#the_lights").fadeTo("slow", 0); $(".turnoff").show(); $(".turnon").hide(); }
Para llamarlas: <?php echo '<script>apagarLuz();</script>'; ?>
<?php echo '<script>encenderLuz();</script>'; ?>
Saludos
Título: Re: problema llamar funcion jquery con php
Publicado por: soru13 en 22 Enero 2012, 19:47 pm
Gracias hermano, funciona perfectamente.
Un saludo! ::)
|