I have a lot of tables in my page. Some tables have Width property defined inline -
style="width:100%; ..."
I need to get all such tables. I tried
$('.Forum_Container table').each(function () {
var $this = $(this);
if ($this.style != undefined) {
if ($this.style.width == '100%') {
...
}
} else {
...
}
});
but $this.style is always undefined. What can cause this problem?
When you do $(this)
you're creating a jQuery object that contains a reference to that DOM element. The style
property is a property of the DOM element itself, not the jQuery object, so trying to access it won't work (because it is undefined).
Either use this
(the actual DOM node) directly - i.e. this.style.width
- or use the functions provided by jQuery to access the information you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With