这是我的single.php隐藏的iframe HTML元素,直到点击按钮或链接(WordPress的)
$id = md5(uniqid(mt_rand(), true));
$text = the_content_devturkeli('<p class="serif">Full Text »</p>');
$last = preg_replace('^<iframe(.*?)></iframe>^', '<a href="javascript:void(0);" onclick="showBlock(\'' . $id . '\')">Click To Watch</a> <div style="display: none;" id="' . $id . '"><embed\\1>\\2</embed><a href="javascript:void(0);" onclick="hideBlock(\'' . $id . '\')"> Hide</a></div>', $text);
unset($id);
echo $last;
我在寻找如何将这个近一个月的时间做的,我不能,因为我不知道怎么用ajax在wordpress中。
我试了很多,但我不知道该怎么做。当你回答这个问题时,请告诉我应该在哪里添加你的代码(function.php或者你应该打开ajax-xxx.js并添加此代码),导致网站无法正常工作时,我添加代码...
<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>
有美好的一天...
简单的隐藏了''iframe' $( 'IFRAME')隐藏();'一旦点击按钮,你可以像这样显示$('iframe')。show();' – JYoThI