$("#id").append('<img src="src" />');
就像这样添加一个img标签,但是为什么添加进去是没有封闭的呢?
在HTML里是这样的<img src="src">
$("#id").append('<img src="src" />');
就像这样添加一个img标签,但是为什么添加进去是没有封闭的呢?
在HTML里是这样的<img src="src">
http://api.jquery.com/jQuery/...
When the parameter has a single tag (with optional closing tag or quick-closing) — $( "<img />" ) or $( "<img>" ), $( "<a></a>" ) or $( "<a>" ) — jQuery creates the element using the native JavaScript .createElement() function.
也就是说不是直接插入的
是先解析html->得出是单个的img->使用createElement
10 回答11.2k 阅读
5 回答4.8k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答2.7k 阅读✓ 已解决
3 回答2.3k 阅读✓ 已解决
3 回答2.2k 阅读✓ 已解决
2 回答2.6k 阅读✓ 已解决
img属于自动封闭标签
另外你那个js代码可以正常运行? 不应该是