首页 \ 问答 \ 无法让.clone()工作(Can't get .clone() to work)

无法让.clone()工作(Can't get .clone() to work)

这可能是一个愚蠢的问题,但我一直在尝试将div( div.frame )复制8次到其父级( div#game ),但它不起作用。

编辑div.frame完全没有复制。 甚至是console.log(frameClone); 显示奇怪的结果

小提琴


jQuery的

(function($) {
    var $game1 = $('div#game1');
    var frameClone = $('div.frame').clone();

    for (var i = 0; i < 8; i++) {
        // frameClone.appendTo('div#game1');
        // frameClone.appendTo($game1);
        // $game1.append(frameClone[0]);
        // $game1.append(frameClone);
        // none of these work
    }

    var $frame = $('div.frame');

})(jQuery);

HTML

<div id="game1">
    <!-- this is one frame. Its cloned and repeated 8 more times -->
    <div data-win="-" class="frame">
        <div class="winsign"></div>
        <div data-sign="-" class="signbox">&t;/div>
        <div data-sign="-" class="signbox"></div>
        <div data-sign="-" class="signbox"></div>
        <div data-sign="-" class="signbox"></div>
        <div data-sign="-" class="signbox"></div>
        <div data-sign="-" class="signbox"></div>
        <div data-sign="-" class="signbox"></div>
        <div data-sign="-" class="signbox"></div>
        <div data-sign="-" class="signbox"></div>
    </div>
</div>

This might be a silly question but I've been trying to copy a div (div.frame) 8 times into its parent (div#game) but its not working.

EDIT : The div.frame is not copied at all. Even console.log(frameClone); shows weird result

FIDDLE


jQuery

(function($) {
    var $game1 = $('div#game1');
    var frameClone = $('div.frame').clone();

    for (var i = 0; i < 8; i++) {
        // frameClone.appendTo('div#game1');
        // frameClone.appendTo($game1);
        // $game1.append(frameClone[0]);
        // $game1.append(frameClone);
        // none of these work
    }

    var $frame = $('div.frame');

})(jQuery);

HTML

<div id="game1">
    <!-- this is one frame. Its cloned and repeated 8 more times -->
    <div data-win="-" class="frame">
        <div class="winsign"></div>
        <div data-sign="-" class="signbox"></div>
        <div data-sign="-" class="signbox"></div>
        <div data-sign="-" class="signbox"></div>
        <div data-sign="-" class="signbox"></div>
        <div data-sign="-" class="signbox"></div>
        <div data-sign="-" class="signbox"></div>
        <div data-sign="-" class="signbox"></div>
        <div data-sign="-" class="signbox"></div>
        <div data-sign="-" class="signbox"></div>
    </div>
</div>

原文:https://stackoverflow.com/questions/17070345
更新时间:2023-09-18 12:09

最满意答案

在新版本中,我们在BrowserStack上可用的所有平台上运行测试。 我们在一些旧的平台上有几个测试失败,但在实践中他们都会工作。 如果您支持旧版本的IE的最大的问题是性能。 但是,它应该仍然正常工作。 它绝对支持所有现代浏览器和移动平台,虽然内置的触控支持是有限的。


When doing new releases we run tests across all platforms available on BrowserStack. We have a couple test failures on some of the older platforms, but in practice they all do work. The biggest concern if you support older versions of IE is performance. However, it should still work properly. It definitely supports all modern browsers and mobile platforms, though built in touch support is limited.

相关问答

更多
  • 您的问题包含正确的答案: Ember.A()只是在您关闭原型扩展时定义Ember.Array一种方式。 你会注意到Ember的内部代码总是使用Ember.A() 。 Your question contains the correct answer: Ember.A() just a way to define an Ember.Array when you have turned off the prototype extensions. You'll notice that Ember's intern ...
  • 如果你使用v2路由器的最新版本的ember,你可以这样做: App.Router.map(function (match) { match("/").to("categoryList", function (match) { match("/").to("foo"); }); }); 在你的catergoryList模板中,放一个{{outlet}}(你可以选择命名) 然后,你想要插入到catergoryList中的模板的路线将如下所示: App.fooRouter = E ...
  • 在新版本中,我们在BrowserStack上可用的所有平台上运行测试。 我们在一些旧的平台上有几个测试失败,但在实践中他们都会工作。 如果您支持旧版本的IE的最大的问题是性能。 但是,它应该仍然正常工作。 它绝对支持所有现代浏览器和移动平台,虽然内置的触控支持是有限的。 When doing new releases we run tests across all platforms available on BrowserStack. We have a couple test failures on s ...
  • 答案很简单,我试图删除这个问题。 所有的ember serve都是服务dist文件夹的内容。 如果您需要配置不同的服务器,请在运行ember build之后取出dist文件夹的内容,并从您自己的服务器上提供。 然后,您可以根据需要将其配置为提供apple-app-site-association文件。 The answer is so simple I'm tempted to just delete the question. All ember serve does is serve the conte ...
  • 我认为这种行为是正确的。 在第二种情况下,您明确告诉ember将每个用户对象包装在代理中(UsersIndexUserController)。 因此,变量用户的日志记录会生成此代理的实例。 从调试perpspective,我完全同意日志助手的行为。 一开始可能不直观,但事实并非如此,你不会看到你在那里工作的真实物体。 想象一下,你的itemController将定义一个名为name的计算属性。 在这种情况下,{{user.name}}将访问控制器上的属性而不是模型。 这可能是一个错误,并且通过帮助程序的这种 ...
  • 这里有一些你可能会遗漏的东西。 如果你包含一个jsbin或jsfiddle而不仅仅是视图文件,那么猜测可能出错的地方会容易得多。 首先,我不知道你的模板文件是什么样的,所以我不知道你是如何注入这个图表的。 我已经能够在这个jsbin中使用Ember视图成功制作一个amchart 。 如果你可以发布更多的代码,我很乐意帮助找出出错的地方,我知道应该更多地展示出原因而不是如何,但这里的信息不足。 There are a few things you might be missing here. If you i ...
  • 更新:是的, Ember.ObjectController是Ember的头等部分,最常用于代理模型的属性以便通过模板进行简单渲染。 有关文档,请参阅http://emberjs.com/api/classes/Ember.ObjectController.html 。 UPDATED: Yes, Ember.ObjectController is a first-class part of Ember and is most frequently used to proxy a model's proper ...
  • 是的,如果您定义的应用程序控制器不是ArrayController,那么您的代码无法工作的主要原因是。 示例: http : //emberjs.jsbin.com/OxIDiVU/1115/edit Yes definitely, the main reason your code wouldn't be working would be if you have an application controller defined that wasn't an ArrayController. Exampl ...
  • 一种可能的方法可能是从数据库模式自动生成客户端模式。 这里已经演示了类似的解决方案(虽然实现是Rails特定的): http : //techblog.fundinggates.com/blog/2013/03/automatically-generate-ember-models-from-rails-serializers/ A possible approach may be to automate the generation of your client side schema from your ...
  • 您需要配置要将输入字段绑定到的属性。 例如: Ember.TextField.reopen({ attributeBindings: ['size', 'maxlength', 'minlength', 'min', 'max', 'step'] }) 这是一个有效的JSFiddle: http : //jsfiddle.net/bZy6b/ 更新:不再需要添加attributeBinding。 Ember现在自动绑定大小,最小值,最大值和步长。 但是,如果需要绑定其他属性,仍可以使用此方法。 版本1 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。