How to target element with inline-style font-size defined in pixels (ex: font-size:12px) in order to modify font-size on a button click.
Can someone help finish this jav
You may try indexOf
on style attribute:
$('.parent').each(function (index, value) {
if (/font-size:[^;]+px/.test($(this).attr('style'))) {
alert(index + ": " + $(this).attr('style'));
}
});
Here is Demo Fiddle
JQuery .css('font-size')
always returns pixels, even if the original size was defined with a different unit. I would use .attr('style')
instead (works with inline styles only) :
var result = $('*').filter(function () {
var style = $(this).attr('style');
return /font-size:[^;]+px/.test(style);
});
Here is a demo : http://jsfiddle.net/wared/8LcD9/.