jQuery在div中的div类中更改html(jQuery changing html inside a div class thats inside a div)

编程入门 行业动态 更新时间:2024-10-14 02:25:43
jQuery在div中的div类中更改html(jQuery changing html inside a div class thats inside a div)

我将如何改变这个的HTML:

<div class="name">President Speech</div>

多数民众赞成在这个div内:

<div class="videobox fl showsearchvideo" id="videoBox7"> <div class="videothumb"> <img src="http://brightcove04.o.brightcove.com/xxxxx/xxxx_xxxxx_xx-xxxxxx.jpg?pubId=xxxxxxx"> </div> <div class="name">President Speech</div> </div>

我试过了:

$('#videoBox7 .name').html('President Speech TEST!');

但那似乎不起作用?

更新

看起来它在视频div之后没有触发运行JS来填充它正在寻找的HTML。

<script type="text/javascript"> $(document).ready(function() { $('#videoBox7 .name').html('President Speech TEST!'); }); </script>

我已将填充视频的JS上传到http://pastebin.com/DNBPNQUQ

更新2

通过放置$('#videoBox7 .name').html('President Speech TEST!');找到了实现这一目标的方法$('#videoBox7 .name').html('President Speech TEST!'); 在onPlaylistLoad js的onPlaylistLoad函数中。

How would i go about changing just the HTML of this:

<div class="name">President Speech</div>

Thats inside this div:

<div class="videobox fl showsearchvideo" id="videoBox7"> <div class="videothumb"> <img src="http://brightcove04.o.brightcove.com/xxxxx/xxxx_xxxxx_xx-xxxxxx.jpg?pubId=xxxxxxx"> </div> <div class="name">President Speech</div> </div>

I've tried:

$('#videoBox7 .name').html('President Speech TEST!');

But that does not seem to work?

update

Seems that its not firing after the videos div runs the JS to populate the HTML thats its looking for.

<script type="text/javascript"> $(document).ready(function() { $('#videoBox7 .name').html('President Speech TEST!'); }); </script>

I have uploaded the JS that populates the videos to http://pastebin.com/DNBPNQUQ

Update 2

Found a way to achieve this by placing the $('#videoBox7 .name').html('President Speech TEST!'); inside the onPlaylistLoad function of the brightstar js.

最满意答案

只有在将HTMLDivElement添加到DOM后才能运行此代码:

$(function(){ $('#videoBox7 .name').html('President Speech TEST!'); });

在与作者聊天之后,很明显问题出在Brightcove Video Player加载新元素以反映视频播放列表。 这一点的明确解决方案是将Brightcove的玩家的事件系统与其元素添加的响应结合起来。

Be sure to run this code only after the HTMLDivElement has been added to the DOM:

$(function(){ $('#videoBox7 .name').html('President Speech TEST!'); });

Following a chat with the author, it became evident the problem was with the Brightcove Video Player loading new elements to reflect a playlist of videos. The clear solution as this point was to tie into the event-system of Brightcove's player to respond after their elements have been added.

更多推荐

本文发布于:2023-08-04 23:14:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1423419.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:类中   div   jQuery   class   changing

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!