Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-15-2012, 03:54 PM   PM User | #1
LimeX
New Coder

 
Join Date: Dec 2011
Posts: 25
Thanks: 7
Thanked 0 Times in 0 Posts
LimeX is an unknown quantity at this point
jQuery Script Not working

Hi!
I have a script that adds "?wmode=transparent" at the end of the src of every Youtube video in a div of #fp.
Here's what I got:
Code:
    var newsrc = $('#fp iframe').attr('src') + '?wmode=transparent';
    $('#fp iframe').attr('src', newsrc);
The problem with this code is that it targets the first iframe, takes the source of that and adds the source of the first video + ?wmode=transparent to all the other videos.
How do I rewrite the code so that it executes once for each iframe it finds?
I'm really new to jQuery and havn't been able to figure this out for a week.
LimeX is offline   Reply With Quote
Old 04-16-2012, 02:29 PM   PM User | #2
harbingerOTV
Senior Coder

 
Join Date: Jan 2005
Location: Memphis, TN
Posts: 1,765
Thanks: 8
Thanked 123 Times in 121 Posts
harbingerOTV will become famous soon enough
Code:
$('#fp iframe').each(function(){
    var newsrc = $(this).attr('src') + '?wmode=transparent';
    $(this).attr('src', newsrc);
});
try that
__________________
Stop making things so hard on yourself.
i is tugbucket :: help raise tugburg :: Whitehaven Kiwanis
harbingerOTV is offline   Reply With Quote
Users who have thanked harbingerOTV for this post:
LimeX (04-16-2012)
Old 04-16-2012, 09:39 PM   PM User | #3
LimeX
New Coder

 
Join Date: Dec 2011
Posts: 25
Thanks: 7
Thanked 0 Times in 0 Posts
LimeX is an unknown quantity at this point
It worked, Thankyou very much!
LimeX is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:06 PM.


Advertisement
Log in to turn off these ads.