我使用多个按钮(动态)打开一个div:
<div class="dialog" title="Player">
<p>YouTube Player here</p>
</div>
在我使用的标题:
<script>
$(function() {
$(".dialog").dialog({
autoOpen: false,
show: {
effect: "blind",
duration: 1000
},
hide: {
effect: "blind",
duration: 1000
}
});
$(".opener").click(function() {
$(".dialog").dialog("open");
});
});
</script>
我按钮使用如下:
foreach ($ytObject->RKT_requestResult->entry as $video) {
return = $ytObject->parseVideoRow($video);
$delimiter = "**";
$VideoContent = explode($delimiter, $return);
if ($count % 2 == 0) {
echo "<div class=\"ResultEven\">";
echo "<button class=\"opener btn\" class=\"btn\">Play</button> ";
echo "<a href = \"" . $VideoContent['0'] . "\" class=\"btn\">Download</a> ";
echo $VideoContent['6'];
echo "</div>";
} else {
echo "<div class=\"ResultOdd\">";
echo "<button class=\"opener btn\" class=\"btn\">Play</button> ";
echo "<a href = \"" . $VideoContent['0'] . "\" class=\"btn\">Download</a> ";
echo $VideoContent['6'];
echo "</div>";
}
$count++;
}
我想将$VideoContent['0']
的值作为<div class="dialog" title="player">
的弹出式内容,以便我可以将YouTube视频直接放在模式上。
答案 0 :(得分:2)
使用以下代码获取值:
$(".opener").click(function() {
var video = $(this).siblings("a").attr("href");
alert(video); //here video will have the value of $VideoContent['0']
$(".dialog").dialog("open");
});
答案 1 :(得分:1)
我做到了。我使用的功能是:
<script>
$(function() {
$(".dialog").dialog({
width: 450,
autoOpen: false,
show: {
effect: "blind",
duration: 1000
},
hide: {
effect: "blind",
duration: 1000
}
});
$(".opener").click(function() {
var video = $(this).siblings("a").attr("href");
var VideoId = video.replace('http://www.youtube.com/watch?v=', '');
var VideoId = VideoId.replace('&feature=youtube_gdata', '');
var youtube = "<embed width=\"420\" height=\"345\" src=\"http://www.youtube.com/v/" + VideoId + "\" type=\"application/x-shockwave-flash\"> </embed>";
$(".dialog").dialog("open").html(youtube);
});
});
</script>
打开它的链接/按钮是
<button class="opener btn" class="btn"><img src="img/Play-icon.png" alt="play" /> Play</button>
echo "<a href = \"" . $VideoContent['0'] . "\" class=\"\"></a> ";
可能有点愚蠢或棘手:P但工作正常! ^ _ ^
实际上按钮是循环的。所以,我使用按钮显示模态和空白href来获取值。而已。 :)