undefined href属性值 [英] undefined href attribute value

查看:101
本文介绍了undefined href属性值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

js

js

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



html


html

<div id="Over_Hidden"></div>
<div id="Wapper">
 
        <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>
          <!--/Header-->
          {body}
 
          <div class="window_loader"></div>
        </div>
        <!--/Container-->
 
</div>
<!--/Wapper-->



控制台给我未定义的原因?


the console give me undefined why ?

推荐答案

' 。播放器a.sc-player')。attr(' href');
console.log(hy);
('.Player a.sc-player').attr('href'); console.log(hy);



html


html

<div id="Over_Hidden"></div>
<div id="Wapper">
 
        <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>
          <!--/Header-->
          {body}
 
          <div class="window_loader"></div>
        </div>
        <!--/Container-->
 
</div>
<!--/Wapper-->



控制台给我一个未定义的原因?


the console give me undefined why ?


href=""



这里需要一个值(链接)。


You need a value (link) here.


我的机器工作正常。

尝试 prop



It is working fine in my machine.
try with prop

 var hy =


这篇关于undefined href属性值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆