ccc

JQuery: Offset

<!DOCTYPE html>
<html>
    <head>
        <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
    </head>
    <body>
        <div id="result" style="width:200px;height:100px;margin:10px;padding:5px;">
            Erase una vez<br>
            dentro de un mundo gris.
        </div>
       
        <script>
            $(function() {
               $("#result").click(function() {
                    console.log("LEFT: "+$(this).offset().left);
                    console.log("TOP: "+$(this).offset().top);
                    console.log("HEIGHT incluyendo margen y padding: "+$(this).outerHeight(true));
                    console.log("WIDTH incluyendo margen y padding: "+$(this).outerWidth(true));
                    console.log("HEIGHT: "+$(this).height());
                    console.log("WIDTH: "+$(this).width());
               });
            });
        </script>
    </body>
</html>

No hay comentarios:

Publicar un comentario