1
<div align="left" style="margin-bottom:3px;"> 
    <b>ID:</b>
    37749
    <b>Active on:</b>
    03/28/2012
</div>

これが私のコンテンツであり、数字を取得する方法です。Jqueryを使用する

4

3 に答える 3

2

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();
});
于 2012-07-19T07:35:17.650 に答える
2
$('div').contents().map(function() {
    if (this.nodeType == 3 && this.nodeValue.replace(/\s/g, '').length !== 0) {
        return this.nodeValue.replace(/\s/g, '');
    }
}).toArray();

デモ

于 2012-07-19T07:47:15.970 に答える
1
var content=$('div').innerHTML();
var arr=content.split("</b>");
var ID=arr[1].split("<b>")[0];
var date=arr[3];
于 2012-07-19T07:34:42.597 に答える