I would like to wrap the image element inside a div
element in Polymer 1.0:
<template>
<img src="" alt="Image preview..." id="avatar" class="avatar">
</template>
<script>
var $container = document.createElement('div');
$container.className += " " + 'resize-container';
var image_target = this.$.avatar;
var image_target_parent = image_target.parentNode;
Polymer.dom(image_target_parent).insertBefore($container, image_target);
</script>
I don't know how to wrap the this.$.avatar
inside $container
.
I'm looking for a jQuery like solution as follows:
image_target.wrap('<div class="resize-container"></div>');
The image is loaded first. Once its loaded I'm trying to put a container around it for handling crop/resize of the image. The idea is simple i should wrap the elementA inside elementB. where elementB is not in the DOM on page load. I don't want to append/prepend to the elementA. – Thiru Sep 04 '15 at 08:46