简体   繁体   English

添加了图像“ A”。 想要以div“ A”,div“ B”和div“ C”显示图像。 怎么样?

[英]Added an Image“A”. Want to Display the image in div“A” , div“B” and div“C”. How?

- I am making an order form with a review page. -我正在制作带有评论页面的订单。 when order form is fully filled, then it automatically send each data to each div on the review page. 当订单填满后,它将自动将每个数据发送到审阅页面上的每个div。 This is what I want. 这就是我要的。

I know I can copy a data into another div by using javascript like 我知道我可以使用javascript将数据复制到另一个div中

<script>
    function filling() {
        var something = $('#input').val();
        document.getElementById("divbox").innerHTML = something;
    }
</script>

but when it's not a data that can be displayed with text(for example, an image or a video), then how can I send the data into another div? 但是当它不是可以与文本一起显示的数据(例如,图像或视频)时,如何将数据发送到另一个div?

  • Thanks to digging really hard the internet, I found an open source contact form with the image attachment function. 由于非常认真地研究互联网,我找到了带有图像附件功能的开源联系人表格。 what's cool about this is, when I attach an image, it resizes and show to client-side. 最酷的是,当我附加图像时,它会调整大小并显示到客户端。

( http://webreflection.blogspot.kr/2010/12/100-client-side-image-resizing.html ) http://webreflection.blogspot.kr/2010/12/100-client-side-image-resizing.html

So, I am modifying this into an order form, and I want, when a client attach an image, it shows to the client the resized version of it, and it also shows in the div on review page. 因此,我将其修改为订购单,并希望当客户端附加图像时,它向客户端显示其调整大小的版本,并且还显示在审阅页面的div中。

How can I do this? 我怎样才能做到这一点? getElementbyClassName or Name did not work because of the "auto resizing script" 由于“自动调整大小的脚本”, getElementbyClassName或Name无效

- I'm sorry for my english being to poor. -对不起,我的英语太差了。 and thank you for your patient to have read this last line. 并感谢您的耐心阅读最后一行。 Have a nice day. 祝你今天愉快。

Few ways: 几种方法:

<script>
    function filling() {
        var something = $('#source').html(); // Can be some element, like another DIV
        $("#divbox").append(something);
    }
</script>

Depending on what you need, can also use clone() ( https://api.jquery.com/clone/ ): 根据您的需要,还可以使用clone()https://api.jquery.com/clone/ ):

function filling(){
    $("#source").clone().append("#divbox");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM