0

RoyalSlider に次のラッパーを使用しています

<a class="rsContent white" href="#">
  <img class="rsImg" src="#" data-color="white" width="2560" height="1440">
</a>

最初の rsContent の data-attribut の値を確認したいので、次のコードを使用します

$('.rsContent').eq(0);また$('.rsContent').first();

これまでのところうまくいきますが、試してみると

$('.rsContent').eq(0).data('color');また$('.rsContent').eq(0).attr('class');

Jquery が返す

undefined

何か案は ?

4

1 に答える 1

0

ログを確認してください..

<html>
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    </head>

    <body>
        <a class="rsContent white" href="#">
          <img class="rsImg" src="#" data-color="white" width="100" height="100">
        </a>
        <script>
            console.log($('.rsContent').first().attr("class")); 
        </script>
    </body>
</html>
于 2015-10-22T23:28:16.830 に答える