crmpicco
crmpicco

Reputation: 17181

jQuery CSS width attribute returning inconsistent on Safari

Below is a snippet of my jQuery where I am grabbing a dropdown and attempting to take the inline width style from it. My problem is that, on Safari I I am not getting a newWidth of 225.

targetSelect is r_select so I can't see why I Safari would return a different width than Firefox, for example.

// get the current select box
targetSelect = $(this);
newWidth = parseInt(targetSelect.css('width'));

My markup:

<select name="r_select" id="r_select" style="width: 225px; height: 50px; float: left;">
    <option>Mickelson</option>
    <option>Montgomerie</option>
    <option>Watson</option>
    <option>Casey</option>
</select>

I should add, that I am not having the same problem with this dropdown:

<select id="r_select_overlay" class="r_select_overlay_test no_style" name="r_select_overlay" style="width: 145px; height: 50px; float:left;">
        <option>Mickelson</option>
        <option>Montgomerie</option>
        <option>Watson</option>
        <option>Casey</option>
</select>

Upvotes: 1

Views: 876

Answers (1)

Billy Moat
Billy Moat

Reputation: 21050

Try getting outerWidth rather than simply width and see if that works.

http://api.jquery.com/outerWidth/

Upvotes: 2

Related Questions