0

I’m using the following wrapper for my RoyalSlider

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

I would like to check the value of the data-attribut for the first rsContent so i use the following code

$('.rsContent').eq(0); OR $('.rsContent').first();

which works fine so far but then when i try

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

Jquery returns

undefined

Any ideas ?

muro
  • 85
  • 2
  • 7

1 Answers1

0

Please Check The Log..

<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>
Ahmad Hammoud
  • 701
  • 1
  • 5
  • 15
  • I've checked the log: undefined – muro Oct 23 '15 at 14:15
  • seems related to the royalsliderplugin because outside of royalsliders scope everything works fine. – muro Oct 23 '15 at 14:16
  • Its means that your code works fine unless i add the royalsliderplugin. – muro Oct 23 '15 at 14:18
  • It could be due to jq conflict. You might need to use: var jq = $.noConflict(); after importing the jq, then call it as $jq('.rsContent).. – Ahmad Hammoud Oct 23 '15 at 14:23
  • i found an alternative by using data-color outside of rsContent. So it works. it seems that there is a conflict with my code and the RS plugin. – muro Oct 31 '15 at 10:34