使用Jquery动态添加HTML返回[Object object]
16lz
2021-01-22
I am trying to define some basic HTML:
我试图定义一些基本的HTML:
<ul id="menu" style="display:none">
<li><a class="actions" href="1">1</a></li>
<li><a class="actions" href="2">2</a></li>
<li><a class="actions" href="3">3</a></li>
</ul>
And append it dynamically using jquery like so:
并使用jquery动态附加它,如下所示:
$('#container').append($('#menu')).show()
However all that's returned is the physical Object:
然而,所有返回的是物理对象:
<div id="container">[object Object]</div>
Can my menu
div be appended in this fashion?
我的菜单div可以这种方式添加吗?
UPDATE: Revised where the show()
is placed, but outcome remains the same
更新:修改show()的位置,但结果保持不变
3 个解决方案
#1
1
While this might work, I would probably run .show() AFTER you append the items to the page. The .append does not expect a function, it's just expecting a DOM element, which may be the cause of your problems.
虽然这可能有效,但我可能会在将项目追加到页面后运行.show()。 .append不期望一个函数,它只是期待一个DOM元素,这可能是你的问题的原因。
更多相关文章
- 是否有办法阻止contenteditable的插入符号出现在IE10的元素上?
- CSS3(jQUery?)当它悬停时隐藏元素“a”,这样就可以显示元素“b”
- 无法使用jquery将活动类添加到当前选定的菜单
- JQuery的。简单的下拉选择菜单行为问题
- 停止鼠标用javascript双击某些元素
- 在量角器中检索子元素的数组
- 4th,Python三级菜单
- 从Python中的列表元素中删除URL
- python selenium-webdriver 定位frame中的元素 (十三)