1
有没有办法使用dojo/dom-construct来创建带有链接的图像元素?我正在寻找相当于下面的HTML代码:Dojo使用链接创建图像
<a href="test.html" target="_blank">
<img src="/pix/byron_bay_225x169.jpg" >
</a>
有没有办法使用dojo/dom-construct来创建带有链接的图像元素?我正在寻找相当于下面的HTML代码:Dojo使用链接创建图像
<a href="test.html" target="_blank">
<img src="/pix/byron_bay_225x169.jpg" >
</a>
是的,这是可能的!
只要做到这一点是这样的:
var anchor= domConstruct.create('a', {
'href': 'test.html',
'target': '_blank'
});
var image= domConstruct.create('img', {
'src': '/pix/byron_bay_225x169.jpg'
});
domConstruct.place(image, anchor);
HTML:
<div data-dojo-attach-point="container"></div>
JS:
var img = domConstruct.create("img", {
src: "/path/image.png",
style: "height:16px;width:16px;",
title: "Image",
onclick: function(){
// onclick event
},
onmouseenter: function(){
// on mouse over event
},
onmouseout: function(){
// on mouse out event
}
);
domConstruct.place(img, this.container);