<div align="left" style="margin-bottom:3px;">
<b>ID:</b>
37749
<b>Active on:</b>
03/28/2012
</div>
これが私のコンテンツであり、数字を取得する方法です。Jqueryを使用する
<div align="left" style="margin-bottom:3px;">
<b>ID:</b>
37749
<b>Active on:</b>
03/28/2012
</div>
これが私のコンテンツであり、数字を取得する方法です。Jqueryを使用する
HTML を追加する必要があります。
<div align="left" style="margin-bottom:3px;">
<b>ID:</b>
<span id="id">37749</span>
<b>Active on:</b>
<span id="active-on">03/28/2012</span>
</div>
jQuery:
$(function () {
var theID = $('#id').text(),
activeOn = $('#active-on').text();
});
$('div').contents().map(function() {
if (this.nodeType == 3 && this.nodeValue.replace(/\s/g, '').length !== 0) {
return this.nodeValue.replace(/\s/g, '');
}
}).toArray();
var content=$('div').innerHTML();
var arr=content.split("</b>");
var ID=arr[1].split("<b>")[0];
var date=arr[3];