Changing .text() modifies container's margins
Using the code from
http://jqueryui.com/button/ and modifying it to change the text of the items clicked on, I am surprised that two of the three items' margins shrink to a minimum rect surrounding the text (the only one that maintains its margins is the input button.
So:
- Should I be surprised? I'm a noobly, so wouldn't be surprised that I shouldn't be... ;)
- How can I maintain the margin of the containers when the text changes?
Thanks!
Bex
Ref:
- <!doctype html>
-
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <title>jQuery UI Button - Default functionality</title>
- <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
- <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
- <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
- <!-- <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css" /> -->
- <script>
- $(function () {
- $("input[type=submit], a, button")
- .button()
- .click(function (event) {
- event.preventDefault();
- $(this).text("xxxxxxxxxxxxxx");
- $(this).val("xxxxxxxxxxxxxx");
- });
- });
- </script>
- </head>
- <body>
-
- <button>A button element</button>
-
- <input type="submit" value="A submit button" />
-
- <a href="#">An anchor</a>
-
-
- </body>
- </html>