Mootools元素注入
很抱歉,如果这已经被涵盖了,我已经看过了,但没有遇到问题 - 答案(我过去在这里找到了我的问题的很多答案 - 继续努力,伙计们+女孩们)
我学习 Mootools 元素注入,我使用它的时间并不长,但我发现它让我对各种用法大开眼界。我的问题是如何构建链接到 url 的新图像元素?例如我如何注射;
<a href="[url]"><img src="[path]" /></a>
我可以将其作为 2 个独立的元素来完成但努力将它们结合为一个元素。感谢您阅读我的问题并提供任何建议。
标记
im sorry if this has already been covered, i have had a look but didn't come acrross a question - answer ( I have found so many answers to my question on here in the past - keep up the good work guys + gals )
Im learning Mootools element injection, I have not been using this for long and I am finding it is opening my eyes to all sorts of usages. My question is how do I construct a new image element that is linked to a url? for example how do I inject;
<a href="[url]"><img src="[path]" /></a>
I can do this as 2 seperate elements & but struggling to combine them as one element. thank you for reading my question and for any advice given.
Mark
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
感谢您的回复,我一直在尝试并根据我的需求提出了以下解决方案
thanks for your responses, ive been experimenting and have come up with the following solution for my needs
使用
Elements.from
,它快速、完全有效且简单。一个明显的缺点是您没有对创建的节点的引用,只有元素集合的引用。
Use
Elements.from
, it's fast, perfectly valid, and simple.An obvious disadvantage is that you have no references to the nodes created, only to the collection of elements.
您可以使用
grab
或注入
到两个新元素(img
和a
) 来嵌套它们:这将生成以下 HTML:
示例: http://jsfiddle.net/tNamz/
You could use
grab
orinject
on two new elements (animg
anda
) to nest them:This will generate the following HTML:
Example: http://jsfiddle.net/tNamz/