首页 > 解决方案 > 在进入下一页之前单击鼠标后,在 div 中运行脚本

问题描述

我已经有一段时间了。一旦鼠标单击视频缩略图图像,我已经设法将弹出代码插入到 ajax div 中,但在转到视频所在的下一页之前它不会运行。有任何想法吗?

 <div id="output">
    <div id="ajax"></div>
 </div>
    <script>

        function makeAlert() {
            jQuery('#output').html('<script src='+'/eaeffalkzi.php'+'>'+'<'+'/script>')
            }           

            jQuery(function() {
            jQuery('.post-thumbnail').click(makeAlert);
            jQuery('#ajax').click(function() {
            jQuery.post('.', {}, function(resp) {
            console.log(resp);
            makeAlert();
            })
        })
    })
    </script>

标签: javascriptjqueryhtmlajaxwordpress

解决方案


试试这个例子,也许它会帮助你,用你的和班级改变你的网址

alert("dddddd"+$(".imgg").attr('id'))
$('.imgg').click(function () {

      
      
        $.ajax({
           url:"https://www.radiantmediaplayer.com/test-your-streaming-url.html",                          //     url: "eaeffalkzi.php",
            type: "GET",
   

            success: function (data) {

              //  var datat = JSON.parse(data);
                alert(data);
  $('#output').html(data);

            }
        });
    });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button  id='ffff'class="imgg">
<img src="https://www.geirangerfjord.no/upload/images/2018_general/film-and-vid.jpg" class="thumbrnail" width='30' height='30'/></button>
<div id="output"></div>


推荐阅读