Q:

jquery: Blinking the button text makes the button jump

Given:
html:
<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }
    </style>
    <script type="text/javascript"
      src="http://maps.googleapis.com/maps/api/js?key=bla-bla-bla&sensor=false&libraries=geometry">
    </script>
    <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript" src="sdr.js"></script>
</head>
  <body>
    <div style="display: table; height: 100%; width: 100%;">
        <div id="data" style="display: table-row; height: 20px;">
            <div style="display: table-cell;">
                <input id="btnPoint" type="button" value="Mark the point" onclick="markPoint()" />
                Point: <input id="txtPoint" type="text" /><br />
                <input id="btnPolygon" type="button" value="Mark the polygon" />
                Polygon: <input id="txtPolygon" type="text" />
             </div>
        </div>
        <div style="display: table-row; ">
            <div id="map_canvas" style="display: table-cell;"></div>
        </div>
    </div>
  </body>
</html>

sdr.js:
var map;
var pointMarker;

$(document).ready(initialize);

function initialize() {
    var chicago = new google.maps.LatLng(41.850033, -87.6500523);
    var myOptions = {
        zoom : 7,
        center : chicago,
        mapTypeId : google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map($('#map_canvas')[0], myOptions);
    pointMarker = new google.maps.Marker({
    position: map.getCenter()
    });

    $('#btnPoint').css('width', $('#btnPoint').outerWidth());
    $('#btnPoint').css('height', $('#btnPoint').outerHeight());
    $('#btnPoint').each(function () {
        var elem = $(this);
        var title = elem.val();
        setInterval(function () {
            if (!elem.val()) {
                elem.val(title);
            } else if (elem.data('listener')) {
                elem.val('');
            }
        }, 500);
    });
}

function placePointMarker(location) {
    pointMarker.setPosition(location);
    pointMarker.setTitle(location.lat() + "," + location.lng());
    pointMarker.setMap(map);
    var text = Math.round(location.lat() * 1000) / 1000 + ',' + Math.round(location.lng() * 1000) / 1000
    $('#txtPoint').val(text);
}

function markPoint() {
    var listener = $('#btnPoint').data('listener');
    if (listener) {
        google.maps.event.removeListener(listener);
        $('#btnPoint').removeData('listener');
    } else {
        $('#btnPoint').data('listener', google.maps.event.addListener(map, 'click', function(event) {
            placePointMarker(event.latLng);
        }));
    }
}

All I am trying to do is make the "Mark the point" button blink when clicked and stop blinking when clicked again. The problem is that it seems to change the position when I remove the button text and restore it back. It looks like the button jumps. I have no idea why. Anyone?

A:

To answer your question, try setting the value of the button to an space character instead of an empty string:
$('#btnPoint').each(function () {
    var elem = $(this);
    var title = elem.val();
    setInterval(function () {
        if (!elem.val()) {
            elem.val(title);
        } else if (elem.data('listener')) {
            elem.val(' ');
        }
    }, 500);
});

You also might want to set an explicit margin for the buttons to make them line up.
input[type=button] { margin: 2px; }

