实例之前的HTML元素,这是我的内容如何隐藏点击按钮(WordPress的)
<iframe width="560" height="315" src="https://www.youtube.com/embed/H76_oByaDZk" frameborder="0" allowfullscreen></iframe>
Game of Thrones S7 XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
我的代码工作,单击按钮,然后加载的iframe,但我想隐藏的iframe我的HTML元素。
这是我的single.php
$id = md5(uniqid(mt_rand(), true));
$text = the_content_devturkeli('<p class="serif">Full Text »</p>');
$last = preg_replace('^<iframe(.*?)></iframe>^', '<a href="#" onclick="showBlock(\'' . $id . '\')">Click To Watch</a> <div style="display: none;" id="' . $id . '"><embed\\1>\\2</embed><a href="#" onclick="hideBlock(\'' . $id . '\')"> Hide</a></div>', $text);
unset($id);
echo $last;
点击按钮后,在视频加载,但我不能隐藏的HTML源代码
我尝试了很多,但我不知道该怎么做。当你回答这个问题时,请告诉我在添加代码时,我应该在哪里添加代码(function.php或smt),导致网站无法正常工作。祝你有美好的一天 。
而且我改变那些
WP-包括/-的template.php后
function the_content_devturkeli($more_link_text = null, $stripteaser = 0, $more_file = '') {
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
return $content;
}
而且header.php中
<script type="text/javascript">
function showBlock(blockId) {
document.getElementById(blockId).style.display = "block";
}
function hideBlock(blockId) {
document.getElementById(blockId).style.display = "none";
}
</script>
哪一部分应该怎么编辑这些。我想隐藏html源代码直到点击
这部分内容不是全部内容。
<iframe width="560" height="315" src="https://www.youtube.com/embed/H76_oByaDZk" frameborder="0" allowfullscreen></iframe>
从你的代码中,有什么想在echo $ last中回显; ? – maulik
内容(iframe和文本),但我不想显示iframe代码html源代码直到点击按钮。 –