Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2011
    Posts
    25
    Thanks
    7
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Senior Coder
    Join Date
    Jan 2005
    Location
    Memphis, TN
    Posts
    1,788
    Thanks
    8
    Thanked 131 Times in 129 Posts
    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

  • Users who have thanked harbingerOTV for this post:

    LimeX (04-16-2012)

  • #3
    New Coder
    Join Date
    Dec 2011
    Posts
    25
    Thanks
    7
    Thanked 0 Times in 0 Posts
    It worked, Thankyou very much!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •