Get width and height of element

Discussion in 'ASP .Net' started by Alejandro Penate-Diaz, May 2, 2005.

  1. Hi. Is there any way of getting an element real size from javascript, when
    this element was previously assigned a width and height of 100%?
    Thanks,
    Alex.
     
    Alejandro Penate-Diaz, May 2, 2005
    #1
    1. Advertisements

  2. In IE you can use the getBoundingRect() method. Look ut up on MSDN for
    documentation and examples. In most cases, you can use offsetHeight and
    offsetWidth of the element, like

    var e = document.getElementById("myDiv");
    alert(e.offsetHeight);
    alert(e.offsetWidth);
     
    Johan Nordberg, May 2, 2005
    #2
    1. Advertisements

  3. Alejandro Penate-Diaz

    Sambathraj Guest

    Sambathraj, May 2, 2005
    #3
  4. Alejandro Penate-Diaz

    suresh44t

    Joined:
    Jan 5, 2013
    Messages:
    1
    Likes Received:
    0
    yes you can do this with the help of jQuery.


    $(document).ready(function(){
    $("div.width").append($("div.width").width()+" px");
    $("div.innerWidth").append($("div.innerWidth").innerWidth()+" px");
    $("div.outerWidth").append($("div.outerWidth").outerWidth()+" px");
    });
     
    suresh44t, Jan 5, 2013
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.