...

View Full Version : Multiple attributes with same name



thumper33
09-13-2010, 11:00 PM
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

Spudhead
09-14-2010, 01:05 PM
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.

eak
09-14-2010, 03:26 PM
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/Using_audio_and_video_in_Firefox

You could then access each source with something like this.


$('#myvideo source').each( function(){ $(this).attr(...)})



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum