0

There is an object with a class .selector For him, it describes the style.

After the page loads done some javascript code which - it does not matter. The result of the - CSS properties assigned to the object width of 110px. How do I use javascript to get the width, which is written for the object in the file of styles?

In other words, how to get value (width = 150px), if the objects are assigned to the width equal 110px?

<style>
.selector {
    min-width: 100px;
    width: 150px;
    max-width: 200px;
}
</style>

<div class="selector"></div>

$(document).ready(function(){
    $('.selector').width('110');
    alert($('.selector').css('width'));
});

Here's an example of how to do so in the ALERT hatched 150 px instead of 100px? http://jsfiddle.net/djmartini/gn3f4590/1/

djmartini
  • 361
  • 1
  • 5
  • 18
  • 3
    `style="110px;` is not a valid style attr. – fuyushimoya Jul 09 '15 at 15:30
  • This is a duplicate.. http://stackoverflow.com/questions/14215256/get-css-value-as-written-in-stylesheet-with-jquery-or-regex – khollenbeck Jul 09 '15 at 15:34
  • 1
    I don't think that duplicate ticket "How to get computed style of a HTMLElement" is the same as what the OP was asking. However it is a duplicate regardless. – khollenbeck Jul 09 '15 at 15:36
  • @Kris Hollenbeck Here's an example of how to do so in the ALERT hatched 150 px instead of 100px? http://jsfiddle.net/djmartini/gn3f4590/1/ – djmartini Jul 09 '15 at 15:51
  • @djmartini, I see it alerting 110.. not 150. And in that example it gets the width value from the element. Not the stylesheet. – khollenbeck Jul 09 '15 at 16:09
  • @Kris Hollenbeck So I'm saying! And I need to get 150 – djmartini Jul 09 '15 at 16:51
  • @djmartini, Refer to this post. -> http://stackoverflow.com/questions/14215256/get-css-value-as-written-in-stylesheet-with-jquery-or-regex This is the same problem you are trying to solve. – khollenbeck Jul 09 '15 at 16:52

1 Answers1

0

jsfiddle: http://jsfiddle.net/man_luck/gn3f4590/

use;

$('.selector').css('width')
man_luck
  • 1,605
  • 2
  • 20
  • 39
  • Here's an example of how to do so in the ALERT hatched 150 px instead of 100px? http://jsfiddle.net/djmartini/gn3f4590/1/ – djmartini Jul 09 '15 at 15:43