【发布时间】:2019-07-28 08:30:23
【问题描述】:
一切都如我所愿,但我觉得我是多余的。我还有 100 个视频要上传,感觉有比继续制作函数更好的方法:ninetyNine()、oneHundred()。
Javascript
<script>
function first(){
$('#videoObj').remove();
$('<iframe id="videoObj" width="1280 " height="720" src="http://www.mysiteetisym.com/videos/KidsOnTrampoline.mp4" frameborder="0" allowfullscreen></iframe>').prependTo('#vholder');
}
function second(){
$('#videoObj').remove();
$('<iframe id="videoObj" width="1280" height="720" src="http://www.mysiteetisym.com/videos/WaterFight.mp4" frameborder="0" allowfullscreen></iframe>').prependTo('#vholder');
}
function third(){
$('#videoObj').remove();
$('<iframe id="videoObj" width="1280 " height="720" src="http://www.mysiteetisym.com/videos/FourWheelingRace.mp4" frameborder="0" allowfullscreen></iframe>').prependTo('#vholder');
}
function fourth(){
$('#videoObj').remove();
$('<iframe id="videoObj" width="1280 " height="720" src="http://www.mysiteetisym.com/videos/CookingWithDebbie.mp4" frameborder="0" allowfullscreen></iframe>').prependTo('#vholder');
}
</script>
HTML
<body>
<div>
<input class="videoBtns" id="firstVideo" type="image" src="images/KidsOnTrampoline.jpg" onClick="first()" />
<input class="videoBtns" id="secondVideo" type="image" src="images/WaterFight.jpg" onClick="second()" />
<input class="videoBtns" id="thirdVideo" type="image" src="images/FourWheelingRace.jpg" onClick="third()" />
<input class="videoBtns" id="fourthVideo" type="image" src="images/CookingWithDebbie.jpg "onClick="fourth()" />
</div>
<div id="vholder"></div>
</body>
【问题讨论】:
-
接受视频名称参数的单个函数怎么样?
-
@Pointy - 这是我的目标,将所有内容都变成一个函数。我目前正在学习 JSON 文件,从它们加载数据似乎很有效。我只是一个反复试验的人,已经达到了我的最终错误。
-
@Marcus,你不需要 JSON,看看给出的答案
-
@iArcadia - 我知道不需要 JSON。我正在学习它,因为每个视频都有很多属性。姓名、地点、人物、时间、日期等。我的最终目标是点击视频的.jpg,以及视频下的所有元数据列表。
-
没问题,我误解了你的评论
标签: javascript jquery html json