我有一个脚本,它使用id="videoLabel1“将皮肤应用到视频标记
$(function() {
$('#videoLabel1').vp1_html5_Video({
skin: 'futuristicChrome',
seekBarAdjust:255
});
});我想修改脚本,以应用皮肤到任何数量的视频标签,每个标签的id="videoLabelX“,其中X是我选择的任何数字,以保持每个id的唯一性。
发布于 2013-02-21 07:29:02
使用starts with选择器http://api.jquery.com/attribute-starts-with-selector/
$(function() {
$('[id^="videoLabel"]').vp1_html5_Video({
skin: 'futuristicChrome',
seekBarAdjust:255
});
});或者向视频标签添加一个类(class="videoLabel")并将其用作选择器
$(function() {
$('.videoLabel').vp1_html5_Video({
skin: 'futuristicChrome',
seekBarAdjust:255
});
});发布于 2013-02-21 07:30:05
您将使用attribute-starts-with选择器(^=):
$('[id^=videoLabel]').vp1_html5_Video({
skin: 'futuristicChrome',
seekBarAdjust:255
});http://api.jquery.com/attribute-starts-with-selector/
然而,如果你能控制,你最好给你的视频标签添加一个类:
<video class="skinnedVideoClass" id="videoLabel4">...</video>JS:
$('.skinnedVideoClass').vp1_html5_Video({ ... });https://stackoverflow.com/questions/14991842
复制相似问题