I am trying to change the width of a button so that it matches the width of the text box above it in jquery. I tried to accomplish this using the following line:
$("#myButton").css("width", $("#textbox").width());
In the code below:
Jsfiddle
JQuery
$('#tabs').tabs(); $("#myButton").css("width", $("#textbox").width());
HTML:
<div id="tabs"> <ul> <li><a href="#tabs-1"> Tab 1</a></li> <li><a href="#tabs-2" id="productTab">Tab 2</a></li> </ul> <div id="tabs-1" class="buttons" class="ui-widget"> </div> <div id="tabs-2"> <table> <tr> <td> <input type="text" id="textbox" /> </td> </tr> <tr> <td> <button id="myButton">My Button </button> </td> </tr> </table> </div> </div>
I believe that since I use tabs, the width of the text box is not immediately available.
source share