1
A
回答
4
<script>
var styles;
$("style").each(function(a,b){
styles = styles + "\n" + b.html();
$(this).remove();
});
$("#style").html('<style>'+ styles +'</style>');
</script>
<div id="style>
</div>
+1
什么是a,b? :D –
+0
@LeahSilber:a =索引(0,1,2,3,4),b是内容 – genesis
1
这里是你如何能在两行做到这一点:
// add a new style element before the first one with all the rules
$('style:first').before('<style type="text/css" id="new">'+$('style').text()+'</style>');
// remove all the style elements except the one added above
$("style:not('#new')").remove();
相关问题
- 1. XPATH获取所有标签<script>和</script>标签
- 2. 获取所有<a>标签的内容与在PHP
- 3. 内容<header>标签
- 4. 获取html标签内/ html标签之间的所有内容
- 5. 获取一个<a>标签
- 6. 提取所有<a>标签从内容
- 7. 获取<script>标签
- 8. Strip <script>标签和PHP之间的所有内容?
- 9. 获取<a></a>标签
- 10. <?php echo file_get_contents如何获取某个标签中的内容
- 11. <script>标签内的标签
- 12. <meta name =“title”>标签和<title></title>标签
- 13. 一个<nav>标签
- 14. 剥离所有<img>标签内的一个div
- 15. 获取标签内容
- 16. 查找标签的内容<Caption>
- 17. 消除<>标签之间的所有内容
- 18. <img>标签内<a>标签只适用于IE
- 19. 如何将<c:out>标签放入<c:if>标签内?
- 20. 如何添加<br>标签链接<img>标签?
- 21. 为什么PHP将所有内容从<head>标签移动到<body>标签?
- 22. 获取所有<PRO>标签都有效在不同层
- 23. 设计标签标题CSS与标签内容连接 - 圆角
- 24. 内<script>标签
- 25. 获取<p></p>标签之间的内容在asp.net
- 26. JQuery:添加现有<option>标签<select>标签
- 27. 删除所有html标签,但<img>或<img/>标签与javascript
- 28. 连接到标签UIView内的标签
- 29. 移除所有<word>标签
- 30. 删除所有<a>标签
什么是这样做的目的是什么? – Shef
清理一些html请求的槽通过ajax –
你想在加载时,或只是一次? – Shef