how can you get a css property before the element is appended?
css
input.inp {
padding:3px 2px 3px 2px;
}
js
var elm = $('<input class="inp" type="text" />');
alert(elm.css('padding-left'));
td.append(elm);
alert(elm.css('padding-left'));
only the second alert retuns the value...
I want the input element to have width:100%.. but since you can't do that (when the input has a padding of its own) I need to set the width in pixels
Get a CSS Property Value You can get the computed value of an element's CSS property by simply passing the property name as a parameter to the css() method. Here's the basic syntax: $(selector). css("propertyName");
To define multiple CSS attributes in jQuery, use the css selector or the addClass() method.
CSS Order Matters In CSS, the order in which we specify our rules matters. If a rule from the same style sheet, with the same level of specificity exists, the rule that is declared last in the CSS document will be the one that is applied.
If it's not in the DOM, then you can't, AFAIK.
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