我想将一个Html元素中的所有属性放入一个数组:就像我有一个jQuery对象,其中html如下所示:
<span name="test" message="test2"></span>
Run Code Online (Sandbox Code Playgroud)
现在一种方法是使用这里描述的xml解析器,但后来我需要知道如何获取我的对象的html代码.
另一种方法是使用jquery,但如何?属性的数量和名称是通用的.
谢谢
顺便说一句:我无法使用document.getelementbyid或类似的东西访问该元素.
是否可以使用jQuery一次删除所有属性?
<img src="example.jpg" width="100" height="100">
Run Code Online (Sandbox Code Playgroud)
至
<img>
Run Code Online (Sandbox Code Playgroud)
我试着$('img').removeAttr('*');没有运气.任何人?
例如我有这样的html:
\n\n<title>Ololo - text\xe2\x80\x99s life</title><div class="page-wrap"><div class="ng-scope"><div class="modal custom article ng-scope in" id="new-article" aria-hidden="false" style="display: block;"><div class="modal-dialog first-modal-wrapper">< div class="modal-content"><div class="modal-body full long"><div class="form-group">olololo<ul style="color: rgb(85, 85, 85);background-color: rgb(255, 255, 255);"><li>texttext</li><li>Filter the events lists by host.</li><li>Create graphs for separate hosts and for the groups of hosts.</li></ul><p style="color: rgb(85, 85, 85);background-color: rgb(255, 255, 255);">bbcvbcvbcvbcvbcvbcvbcvb</p></div></div></div></div></div></div><title>cvbcbcvbcvbcvbccb</title><div class="page-wrap"></div></div>\nRun Code Online (Sandbox Code Playgroud)\n\n我怎样才能从这样的html中删除所有样式类id等?
\n\n我有这样的正则表达式:
\n\n/<([a-z][a-z0-9]*)[^>]*?(\\/?)>/i\nRun Code Online (Sandbox Code Playgroud)\n\n怎么了?如何借助正则表达式删除所有html属性?
\n\n这是小提琴:
\n\n\n