Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
注意使用JQuery创建特定元素(按id)?_Jquery_Events_Document Ready - Fatal编程技术网

注意使用JQuery创建特定元素(按id)?

注意使用JQuery创建特定元素(按id)?,jquery,events,document-ready,Jquery,Events,Document Ready,当用户启动某些操作时,我将把swf加载到div标记中。div标记的id是container,嵌入的swf标记id将是swf_content。我希望能够在加载swf_内容标记时为其设置一个变量。比如: $("#swf_content").ready(function() { SWF = $("#swf_content").get(0); }) 假设在用户执行任意操作之前不会加载,那么最好的方法是什么?最简单的方法是使用,请参阅动态嵌入部分 <!DOCTYPE html PUBLIC

当用户启动某些操作时,我将把swf加载到div标记中。div标记的id是container,嵌入的swf标记id将是swf_content。我希望能够在加载swf_内容标记时为其设置一个变量。比如:

$("#swf_content").ready(function() {
    SWF = $("#swf_content").get(0);
})

假设在用户执行任意操作之前不会加载,那么最好的方法是什么?

最简单的方法是使用,请参阅动态嵌入部分

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
      <head>
        <title>SWFObject dynamic embed - step 3</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <script type="text/javascript" src="swfobject.js"></script>

        <script type="text/javascript">
        swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0");
        </script>

      </head>
      <body>
        <div id="myContent">
          <p>Alternative content</p>
        </div>
      </body>
    </html>

我知道如何使用swfobject:p,我正在研究如何知道何时将对象添加到DOM中。同样,请参见此处的embedSWF文档,最后一个参数是在成功或失败的swf嵌入时触发的回调函数,另请参见此处的示例