【发布时间】:2012-03-28 10:21:20
【问题描述】:
有没有一种简单的方法可以使用 jquery/javascript 从字符串 (html) 中获取数组,例如:
html:
<h1>this is a test</h1>
<p>This is a test</p>
<p>This is a test</p>
<h2>this is a test</h2>
<p>This is a test</p>
到一个数组:
array[0]['tag'] = 'h1'
array[0]['value'] = 'this is a test'
array[1]['tag'] = 'p'
array[1]['value'] = 'this is a test'
array[2]['tag'] = 'p'
array[2]['value'] = 'this is a test'
array[3]['tag'] = 'h2'
array[3]['value'] = 'this is a test'
array[4]['tag'] = 'p'
array[4]['value'] = 'this is a test'
谢谢!
【问题讨论】:
标签: javascript jquery html arrays