奇怪的 DOM 树 JavaScript 问题
我在使用此网站时遇到问题 -
http://thestamp.umd.edu/canvastest/test。 html
我正在尝试使用 JavaScript 构建一个简单的 HTML 电子邮件程序来渲染和生成 HTML,然后将其发送到页面等。
但是,当您创建三个段落(箱を作る)然后尝试移动时第三个上来onclick 被 swapup('render2');它只是将其移动到顶部。
但奇怪的是当你粘贴 swapup('render2'); 时在控制台中,它工作得很好。当我不以任何身份引用“this”时,为什么 onclick 行为会有所不同?
I am having an issue with this site -
http://thestamp.umd.edu/canvastest/test.html
I'm trying to build a simple HTML emailer with JavaScript to render and generate HTML which will then be sent to a page, etc.
However, when you create three paragraphs (箱を作る) and then try to move the third one up with the onclick being swapup('render2'); it just moves it to the top.
But the odd thing is when you paste swapup('render2'); in the console, it works just fine. Why should the onclick behaviour be different when I'm not referencing 'this' in any capacity?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的问题是你调用了两次 swapup 。看一下 HTML,
span 和 input 都调用了 swapup。看起来交换在某个点上被动态分配给跨度,这可能会导致你的问题......不过,我必须深入挖掘才能弄清楚。
编辑:
我现在明白了。在你调用的交换函数中,
我不确定你是否有意这样做......你能澄清一下吗?
编辑2:
我认为你需要将
boxes.js第23-24行更改为
Your problem is that you are calling swapup twice. Take a look at the HTML
both span and input are calling swapup. It looks like swapup is being dynamically assigned at some point to the span, which may be causing your problem... I'll have to dig a little more to figure it out though.
EDIT:
I see now. In your swapup function you are calling
I'm not sure if you intended that or not... can you clarify?
EDIT 2:
I think you need to change
in boxes.js lines 23-24 to