0

最終的には、次のように表示するオブジェクトを取得したいと考えています。

'0': {
       '0': {
              label: 'Book:',
              content: 'a book name',        
       }, 

       '1': {
              label: 'Video:',
              content: 'a video name',        
       }, 

       '2': {
              label: 'Audio:',
              content: 'an audio name',        
       },              
  }, 

'1': {
       '0': {
              label: 'Book:',
              content: 'another book name',        
       }, 

       '1': {
              label: 'Video:',
              content: 'another video name',        
       }, 

       '2': {
              label: 'Audio:',
              content: 'another audio name',        
       },              
  }

objDL が定義されていない理由がわかりません

4

1 に答える 1

1

.containers、dts、およびs を個別に反復処理しないでくださいdd。objDT/DD がどのコンテナーから派生しているかを忘れています。また、結果にはオブジェクトの代わりに配列を使用します。

var objDL = [];
$("dl").each(function(i) {
    objDL[i] = [];
    $(this).children("dt").each(function(j) {
        var $this = $(this);
        objDL[i][j] = {
            title: $this.text(),
            description: $this.next("dd").text();
        };
    });
});
于 2013-02-01T15:31:30.517 に答える