實例之前的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源代碼直到點擊按鈕。 –