Javascript-在运行时访问嵌入标记并追加文本
在html源代码中,我有以下内容:Javascript-在运行时访问嵌入标记并追加文本,javascript,jquery,text,append,embed,Javascript,Jquery,Text,Append,Embed,在html源代码中,我有以下内容: <embed width="100%" id="video-player-flash"... 您可以使用: <script type="text/javascript"> $(document).ready(function(){ $("#video-player-flash").attr("allownetworking", "internal"); }); </script> $(文档).
<embed width="100%" id="video-player-flash"...
您可以使用:
<script type="text/javascript">
$(document).ready(function(){
$("#video-player-flash").attr("allownetworking", "internal");
});
</script>
$(文档).ready(函数(){
$(“#视频播放器闪存”).attr(“allownetworking”、“internal”);
});
您可以在此处阅读jQueryattr
函数:
使用jQuery时,无需使用document.getElementById
-当您希望在页面中选择元素时,最好使用jQuery选择器。@gpojd question updated。。。thanksit不起作用…也许问题是在iframe中?jQuery(document).ready(function(){$(“#视频播放器flash”).attr(“allownetworking”,“internal”);});对吗?不起作用…您的嵌入式视频位于IFRAME内部,而此代码位于IFRAME外部?是的,在外部…因为IFRAME是由外部脚本生成的OK好的,请尝试:document.frames[“MyIFrameID”]。$(“#视频播放器flash”).attr(“allownetworking”,“internal”);
<script type="text/javascript">
jQuery(document).ready( function() {
document.video-player-flash.innerHTML += 'allownetworking="internal"';
});
</script>
<script type="text/javascript">
jQuery(document).ready( function() {
document.getElementById("video-player-flash").innerHTML += 'allownetworking="internal"';
});
</script>
<script type="text/javascript">
jQuery(document).ready( function() {
var playerep = document.getElementById('video-player-flash');
playerep.setAttribute("allownetworking", "internal");
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$("#video-player-flash").attr("allownetworking", "internal");
});
</script>