简体   繁体   English

如何触发页面上多个动态生成的ID的fitVid?

[英]How do I trigger fitVids for multiple, dynamically generated ids on a page?

I'm working on a responsive tumblr-theme based on the 1140GRID. 我正在研究基于1140GRID的响应式tumblr主题。 To make the static videos fit the column, I used the jquery fitvids plugin. 为了使静态视频适合该列,我使用了jQuery fitvids插件。 My setup code looks like this: 我的设置代码如下所示:

  $(document).ready(function(){
    $("#post_{PostID}").fitVids();
  });

and the accompanying html like this: 和随附的html像这样:

<div class="container">
  <div class="row">
    <div class="ninecol"> //grid I want it to fit into
      {Block:Video}     
        <div id="post_{PostID}">
          {Video-500}
        </div>
      {/Block:Video}
    </div>
  </div>
</div>            

How do I trigger fitVids for multiple, dynamically generated ids on a page? 如何触发页面上多个动态生成的ID的fitVid?

Thank you! 谢谢!

You may want to put that closing DIV inside the video block. 您可能需要将结束的DIV放在视频块中。

<div class="container">
  <div class="row">
    <div class="ninecol"> //grid I want it to fit into
      {Block:Video}     
      <div id="post_{PostID}">
        {Video-500}
      </div>
      {/Block:Video}
    </div>
  </div>
</div>

Then, you could target all the subdivs of ninecol. 然后,您可以定位ninecol的所有细分。

<script>
$(document).ready(function(){
  $('.ninecol > div').fitVids();
});
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何选择在Jquery中由循环动态生成的多个ID并将其传递给AJAX? - How can I select multiple ids generated by a loop dynamically in Jquery and pass them to AJAX? 如何在角度4中动态生成的元素上触发click事件? - How can I trigger a click event on element generated dynamically in angular 4? 如何获取动态生成的模态ID - how to get the dynamically generated IDs of Modal 如何为自动生成的按钮分配不同的 ID? (角度) - How do I assign different IDs to automatically generated buttons? (Angular) 如何将由AngularJs动态生成的HTML页面导出为PDF? - How do I export my HTML page which is dynamically generated by AngularJs as PDF? 如何使用jQuery将页面元素与动态生成的元素包装在一起? - How do I wrap a page element with a dynamically generated element using jQuery? 如何使用事件侦听器为表单字段动态分配ID? - How do I dynamically assign IDs to form fields with event listeners? 如何将自动递增的 id 添加到动态大小的可观察数组? - How do I add autoincrementing ids to a dynamically sized observable array? 如何处理Vue.js动态生成的多种表单 - How do I process multiple forms generated dynamically with Vue.js jQuery .change值,用于在动态生成的名称/ id上匹配的多个项目 - jQuery .change value for multiple items matched on dynamically generated names/ids
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM