javascript - jQuery .text() values are empty - iframe -


i have strange behavior assigning value variable jquery. can't values form .text(). other functions on other sites work. spotify problem. when elements loaded doesn't stuff out.

function:

    function gettrackspotify() {     var track;      track = $("#radio-artist .outgoing").text() + " - " + $("#radio-track .outgoing").text(); // both elements empty. please check code in pastebin.     console.log(track);     return track; } 

i coding 10 hours today, maybe brains burned much, , can't see nothing..

html:

<div id="radio-track-info"> <h2 id="radio-track">     <a class="outgoing" href="https://play.spotify.com/album/3g18adjiqo3bnlivzrenb1/track/04o7scgvdejixinhtu4nxl/action/select">   see me </a> </h2> <h2 id="radio-artist">     <a class="outgoing" href="https://play.spotify.com/artist/73sibhcqh3z3nyqhkz7fol">   childish gambino </a> </h2> 

thank you.

ok advice inspect dom hard. in case had 10 dom iframes, never access proper element. how did in end:

    function gettrackspotify() {     var artist;     var title;      if($('#app-player').length > 0){             artist = $('#app-player').contents().find("#player").find("#track-artist").text();             title = $('#app-player').contents().find("#player").find("#track-name").text();     }      return (artist != '') ? artist + ' - ' + title + ' - spotify' : 'music every moment - spotify'; } 

...where #app-player id of iframe.

cheers.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -