1

The following line of code:

$border_width = parseInt($('#jma_border_element').css('border-width'));
console.log($border_width);

The excepted value 5. It works in chrome, but nan in firefox(18.0.2)

7
  • try either border-left-width or borderWidth Feb 25, 2013 at 14:57
  • Show the HTML this applies to. A simple jsFiddle has no issues with your code.
    – j08691
    Feb 25, 2013 at 14:59
  • It could fail because border-width could be '' or something like px which is not a valid number Feb 25, 2013 at 15:02
  • which is the browser used? Feb 25, 2013 at 15:04
  • try alerting $('#jma_border_element').css('border-width') and see if it is a valid int in firefox
    – Pete
    Feb 25, 2013 at 15:06

1 Answer 1

1

border-width is inadvisable to use since the four borders can all have a different width, style and colour, so some browsers only recognise the individual values. If you know for sure that they're all the same then simply use this...

$border_width = parseInt($('#jma_border_element').css('border-left-width'), 10);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.