[英]Using jQuery read more with iframe
I'm using this but in some browsers I cannot get the iframe to display so I've added a function for it to be refreshed which works great. 我正在使用它,但是在某些浏览器中我无法显示iframe,因此我添加了一个刷新功能,效果很好。
The only problem is that this refreshes all iframe instead of just the one in the div being expanded. 唯一的问题是,这会刷新所有iframe,而不只是刷新div中正在扩展的iframe。
<script type="text/javascript">
$('.box').readmore({
speed: 500,
collapsedHeight:112,
embedCSS: false,
moreLink: '<a href="#" class="btn">Read more</a>',
lessLink: '<a href="#" class="btn">Read Less</a>',
afterToggle: function(trigger, element, expanded) {
if( expanded) {
$( 'iframe' ).attr( 'src', function ( i, val ) { return val; });
}
}
});
</script>
I know I could just put a class or an id on the iframe itself but this is not an option in my situation. 我知道我可以在iframe本身上放一个类或ID,但这在我的情况下不是一种选择。
How can I resolve this? 我该如何解决?
$( 'iframe' ).attr( 'src', function ( i, val ) { return val; });
使用“ this”关键字
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.