Javascript 在引导模式下打开href

Javascript 在引导模式下打开href,javascript,jquery,html,twitter-bootstrap,Javascript,Jquery,Html,Twitter Bootstrap,我有多个视频显示在模态。我不想为每个按钮创建模型来显示视频速率。我想在所有按钮下以单一模式显示所有视频 我找到了一个函数。它在旧版本的引导程序上运行良好,但当我切换到引导程序3.3.7时,它并没有在模式中显示视频 这是我的html <a href="https://www.youtube.com/embed/7iPoBjiFdho/" class="btn bootpopup" data-toggle="modal" data-target="#popupModal">Open mo

我有多个视频显示在模态。我不想为每个按钮创建模型来显示视频速率。我想在所有按钮下以单一模式显示所有视频

我找到了一个函数。它在旧版本的引导程序上运行良好,但当我切换到引导程序3.3.7时,它并没有在模式中显示视频

这是我的html

<a href="https://www.youtube.com/embed/7iPoBjiFdho/" class="btn bootpopup" data-toggle="modal" data-target="#popupModal">Open modal</a>

<div id="popupModal" class="modal fade" tabindex="-1" role="dialog">
    <div class="modal-dialog">
         <div class="modal-content">
        <div class="modal-body">
            <iframe width="100%" height="315" src="" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
        </div>
        </div>
    </div>
</div>
这里是js函数

</script>
     <script type='text/javascript'>

        $(document).ready(function() {

            $('.bootpopup').click(function(){
    var frametarget = $(this).attr('href');
  var targetmodal = $(this).attr('data-target');
  if (targetmodal == undefined) {
    targetmodal = '#popupModal';
  } else { 
    targetmodal = '#'+targetmodal;
  }
  if ($(this).attr('title') != undefined) {
    $(targetmodal+ ' .modal-header h3').html($(this).attr('title'));
    $(targetmodal+' .modal-header').show();
  } else {
     $(targetmodal+' .modal-header h3').html('');
    $(targetmodal+' .modal-header').hide();
  }  
    $(targetmodal).on('show', function () {
        $('iframe').attr("src", frametarget );   
    });
    $(targetmodal).modal({show:true});
  return false;

});

        });

        </script>

尝试这样做,它现在应该可以工作了:

$(document).ready(function() {

   $('.bootpopup').click(function(){
   var frametarget = $(this).attr('href');
   var targetmodal = $(this).attr('data-target');
   if (targetmodal === undefined) {
     targetmodal = '#popupModal';
   }

   if ($(this).attr('title') != undefined) {
     $(targetmodal+ ' .modal-header h3').html($(this).attr('title'));
     $(targetmodal+' .modal-header').show();
   } else {
     $(targetmodal+' .modal-header h3').html('');
     $(targetmodal+' .modal-header').hide();
   }   
   $('iframe').attr("src", frametarget );   

   $(targetmodal).modal({show:true});
   return false;
   });
});

乔治:你说的小提琴是什么意思?是的。在这里处理您的问题不客气:您也可以这样做: