Firefox isn't getting .each() or all elements
I have a bit of code:
$('.audio_player embed').each(function() {
$开发者_高级运维(this).attr('wmode','transparent').wrap('<div></div>');
console.log($(this));
});
What this code does is finds all embed within divs with a class of .audio_player and then for each of them it will change the wmode to transparent and wrap it in a div.
This code is working perfectly in Chrome and all of the embeds are getting the wmode changed. However in Firefox, its only getting the first instead of all of them.
I added the console.log to see if they are getting picked up. And in Chrome, its picking up multiple embeds but not in Firefox.
Any help would be really appreciated. Thanks.
Its my fault - it's not browser specific. I noticed that when I load a second page - it doesn't find the embed, so it doesn't add the wmode. But when I load a third page, the embed on the second page works and their page doesn't. I will investigate this further. I think a delay before the function might be in order.
try this, it is a little more verbatim and using each, made few small modifications:
$(document).ready(function () {
$("div.audio_player").each(function() {
$("embed", this).attr("wmode","transparent").wrap("<div />");
});
});
added ready
精彩评论