javascript - How can I pass a variable in the path -
i have script , want play song has name 'pr_id', how can write in path? thanks!
$(document).ready(function(){ var pr_id = document.getelementbyid('id') $("#jquery_jplayer_1").jplayer({ ready: function (){ $(this).jplayer("setmedia", { mp3:"/sounds/[pr_id].mp3" }); }, swfpath: "js", supplied: "mp3", wmode: "window" }); });
like so:
$(document).ready( function() { var pr_id = document.getelementbyid('id'); $("#jquery_jplayer_1").jplayer({ ready: function() { $(this).jplayer("setmedia", { mp3:"/sounds/" + pr_id + ".mp3" }); }, swfpath: "js", supplied: "mp3", wmode: "window" }); }); concatenate string variable :), unfortunately, unlike other languages it's not easy include variables in string, , have split string bit concatenation.
Comments
Post a Comment