2013-05-03 86 views
-1

我正在使用此代码将“顶部”属性值添加到所有带有抄本单词的ID。过滤多个ID以添加属性

这里是DIV看看如何: -

<div id="transcript36a_page2" class="pop-out" style="display: block; position: fixed; opacity: 1; z-index: 11400; left: 50%; margin-left: -425px; top: 157px; margin-top: 0px;"> 
    <a class="modal_close" href="#"><img src="images/empty.png" alt=""></a> 
    <img src="./images/6a.png" border="0" alt=""> 

jQuery代码我用的是: -

$(this).leanModal(
     { 
      top: $(this).filter('[id*="transcript"]')[0] ? 500 : null, 
      closeButton: ".modal_close, .modal_close_for_shoutout" 
     } 
    ); 

这与任何股利增加了 “顶” 值成绩单在里面。问题是,现在我想要它过滤所有的divs shoutout也是。有没有什么有效的方法可以过滤多个DIV ID?

感谢

回答

1
$(this).leanModal({ 
    top: $(this).filter(function() { 
       return this.id.indexOf('transcript') != -1 || 
        this.id.indexOf('shoutout') != -1 
      }).length ? 500 : null, 
    closeButton: ".modal_close, .modal_close_for_shoutout" 
}); 
+0

谢谢adeneo :) – Steve 2013-05-03 21:22:03

+0

不客气! – adeneo 2013-05-03 21:23:17