Dojo创建带有链接的映像

m1m5dgzv  于 2022-12-16  发布在  Dojo
关注(0)|答案(2)|浏览(192)

有没有办法使用dojo/dom-construct来创建一个带有链接的图像元素?我正在寻找以下HTML代码的等价物:

<a href="test.html" target="_blank">
    <img src="/pix/byron_bay_225x169.jpg" >
</a>
9udxz4iz

9udxz4iz1#

是的,这是可能的!
就像这样做:

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);
j8yoct9x

j8yoct9x2#

超文本:

<div data-dojo-attach-point="container"></div>

联森:

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);

相关问题