www.webdeveloper.com
Results 1 to 1 of 1

Thread: jQuery position

  1. #1
    Join Date
    Aug 2011
    Posts
    8

    jQuery position

    I'm using the following code with the script attached as a file to a page.
    For whatever reasons it keeps showing the coordinates of the Save button as 0, 0 even though the button is in a middle of the page.
    It finds the button, so it alerts 'Save' and everything.

    Any ideas why it's happening?

    Code:
    var saveButtonValue = "Save";
    
    $(document).ready(function () {
        alert('j');
        findButtonSides();
    });
    
    function findButtonSides() {
        saveButton = findButtonByValue(saveButtonValue);
        var sb = $(saveButton);
        var position = sb.position();
    
        alert(position.left + ', ' + position.top);
    }
    
    function findButtonByValue(buttonValue) {
        var aButton = document.getElementsByTagName("input");
        var returnElement
        for (i = 0; i < aButton.length; i++) {
            var b = aButton[i];
            if (b.value == buttonValue) {
                alert(b.value);
                return b;
            }
        }
    }
    Last edited by gr_m; 10-03-2011 at 09:51 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles