undefined href属性值javascript

时间:2016-01-11 16:26:01

标签: javascript jquery undefined href

我想要href值,但是这给了我未定义的,为什么呢?

var hy = $('.Player a.sc-player').attr('href');

console.log(hy);

<div id="Container">
  <header>
    <div id="Player">
      <div class="Player">
        <a href="https://soundcloud.com/rapzilla/andy-mineo-stop-the-traffic" class="sc-player"></a>
        <p>hellow</p>
        <a href="" class="download_song">Download</a>
      </div>
    </div>
    <!--/Player-->
  </header>**strong text**

1 个答案:

答案 0 :(得分:0)

$(document).ready(function(){

    alert($('.Player a.sc-player').attr('href'))
});