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 to the CF scene
    Join Date
    Sep 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Multiple attributes with same name

    Hi,

    First post, nice to meet you guys.

    I'm using jquery to manipulate the src attr in html5's video tag. Since you can have multiple src attributes accounting for different browsers, one after the other, i.e.:

    <video
    src="/video/video1.mp4"
    src="/video/video1.ogv"
    poster="/img/poster.jpg"
    width="580"
    height="311"
    />

    how would I address the each src tag??

    Obviously I'm able to grab the first attr with something like:

    $("video").attr({ src: mainVideo, type: 'video/mp4', width: '580', height: '311' });

    but I can't do anything with the second...

    Any suggestions would be appreciated.

    Thumper

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Hmmm. I can't see any way to do this. It always just returns the first src value. In fact, $("video[src$='ogv']") doesn't even find a matching element.

    Sorry If I stumble across anything, I'll post it.

  • #3
    eak
    eak is offline
    Regular Coder eak's Avatar
    Join Date
    Jun 2002
    Location
    Nashville, TN
    Posts
    354
    Thanks
    0
    Thanked 26 Times in 26 Posts
    You cannot have duplicate attributes.

    With HTML5, there is a <source> tag that will allow you to define multiple sources.

    https://developer.mozilla.org/En/Usi...deo_in_Firefox

    You could then access each source with something like this.

    Code:
    $('#myvideo source').each( function(){ $(this).attr(...)})
    eak | "Doing a good deed is like wetting your pants; every one can see the results, but only you can feel the warmth."


  •  

    Posting Permissions

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