-4
rated 0 times
[
3]
[
7]
/ answers: 1 / hits: 19685
/ 12 Years ago, mon, august 27, 2012, 12:00:00
I have several iframe
s on the page. There are some elements with classname test
inside of them. I need to set any style
to them.
When I have only one iframe
, I can use next construction:
$('#iframeId').contents().find('.test').css({background: '#f00'});
But I have several iframe
s, so it would be great not to set concrete iframe
and use construction like:
$('.test').css({background: '#f00'});
But it doesn't work, of course.
I used native getElementsByClassName
before, but it doesn't work in IE8
, where defect appears.
It may be stupid question, but.. Is there any construction like:
$(getElementById('something')).css({background: '#f00'});
It would be very helpful. I mean, wrap JavaScript
object with jQuery
and then use jQuery
methods with them.
Update: I solved this problem with next construction:
[].forEach.call(document.getElementById('something').querySelectorAll('.test'), function (el) {
el.style.backgroundColor = '#f00';
});
But it's still doesn't work for IE8
.
More From » jquery