1

我正在使用打开单个 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>&nbsp;";
        echo "<a href = \"" . $VideoContent['0'] . "\" class=\"btn\">Download</a>&nbsp;";
        echo $VideoContent['6'];
        echo "</div>";
    } else {
        echo "<div class=\"ResultOdd\">";
        echo "<button class=\"opener btn\" class=\"btn\">Play</button>&nbsp;";
        echo "<a href = \"" . $VideoContent['0'] . "\" class=\"btn\">Download</a>&nbsp;";
        echo $VideoContent['6'];
        echo "</div>";
    }
    $count++;
}




我想将 的值$VideoContent['0']作为弹出内容,<div class="dialog" title="player">以便我可以将 YouTube 视频直接放在模态框上。

4

2 回答 2

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");
 });
于 2013-07-09T12:03:11.643 回答
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" />&nbsp;Play</button>

echo "<a href = \"" . $VideoContent['0'] . "\" class=\"\"></a>&nbsp;";

可能有点愚蠢或棘手:P 但工作正常!^_^

实际上,按钮是一个循环。所以,我使用按钮来显示模式和空白 href 来获取值。而已。:)

于 2013-07-19T10:27:59.770 回答