2016-07-29 17 views
0

このJavaScriptに動的なデータを追加したいと思います。 これを行うにはどうすればいいですか?JavaScriptで配列に項目を動的に追加するにはどうすればよいですか?

$(document).ready(function(){ 
     new jPlayerPlaylist({ 
     jPlayer: "#jquery_jplayer_2", 
     cssSelectorAncestor: "#jp_container_2" 
    }, [ 
     { 
      title:"Do Pag Mar aur Bhul Ja", 
         mp3:"http://download.apunkabollywood.us/songs/Audio/indian/movies/One Night Stand (2016)/01 - Do Peg Maar - Neha Kakkar @ fmw11.com.mp3", 
     }, 
     { 
      title:"Your Face", 
      mp3:"http://www.jplayer.org/audio/mp3/TSP-05-Your_face.mp3", 
      oga:"http://www.jplayer.org/audio/ogg/TSP-05-Your_face.ogg" 
     }, 
     { 
      title:"Cyber Sonnet", 
      mp3:"http://www.jplayer.org/audio/mp3/TSP-07-Cybersonnet.mp3", 
      oga:"http://www.jplayer.org/audio/ogg/TSP-07-Cybersonnet.ogg" 
     }  
    ], { 
     swfPath: "musicPlayerfiles/dist/jplayer", 
     supplied: "oga, mp3", 
     wmode: "window", 
     useStateClassSkin: true, 
     autoBlur: false, 
     smoothPlayBar: true, 
     keyEnabled: true 
    }); 
}); 
+3

[配列への追加]の可能な重複(http://stackoverflow.com/questions/351409/appending-to-array) – Tibrogargan

+0

参照[Array.prototype.push()](HTTPS: //developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/push); JavaScriptの配列に追加する方法 – cdaiga

+0

追加したいデータはどこから来ますか? – nnnnnn

答えて

0
U can Write Declare Like Array then you can 



var jPlayerPlaylist=[{ 
      jPlayer: "#jquery_jplayer_2", 
      cssSelectorAncestor: "#jp_container_2" 
     }, [ 
      { 
       title:"Do Pag Mar aur Bhul Ja", 
          mp3:"http://download.apunkabollywood.us/songs/Audio/indian/movies/One Night Stand (2016)/01 - Do Peg Maar - Neha Kakkar @ fmw11.com.mp3", 
      }, 
      { 
       title:"Your Face", 
       mp3:"http://www.jplayer.org/audio/mp3/TSP-05-Your_face.mp3", 
       oga:"http://www.jplayer.org/audio/ogg/TSP-05-Your_face.ogg" 
      }, 
      { 
       title:"Cyber Sonnet", 
       mp3:"http://www.jplayer.org/audio/mp3/TSP-07-Cybersonnet.mp3", 
       oga:"http://www.jplayer.org/audio/ogg/TSP-07-Cybersonnet.ogg" 
      }  
     ], { 
      swfPath: "musicPlayerfiles/dist/jplayer", 
      supplied: "oga, mp3", 
      wmode: "window", 
      useStateClassSkin: true, 
      autoBlur: false, 
      smoothPlayBar: true, 
      keyEnabled: true 
     }]; 
    and the Array Should like This 


jPlayerPlaylist = 
    [ObjectcssSelectorAncestor: "#jp_container_2"jPlayer: "#jquery_jplayer_2"__proto__: Object, Array[3]0: Objectmp3: "http://download.apunkabollywood.us/songs/Audio/indian/movies/One Night Stand (2016)/01 - Do Peg Maar - Neha Kakkar @ fmw11.com.mp3"title: "Do Pag Mar aur Bhul Ja"__proto__: Object1: Object2: Objectlength: 3__proto__: Array[0], Object] 

You want add one more object U can Push In to " jPlayerPlaylist " this Array To Use This Flow 
+0

Thaのデータはです –

+0

これを追加するhoow教えてください –

関連する問題