lundi 2 novembre 2015

if class contains data-type

Im trying to write a if-else statement that if the class element contains the data-type, it will do something, but im not sure if im writing it correctly as the statement is being commented out with //

if (//div[@class='_3d5d'][contains(ul/li[1], "recent")]/data-key()){
    //do something
}
else if (//div[@class='_3d5d'][contains(ul/li[2], "year_2015")]/data-key()){ 
    //do something
}

Below is the html snippet

<div class="_5ay5">
    <div class="_18fs">
    <div id="PageScrubberPagelet_153681831442414"          
     data-referrer="PageScrubberPagelet_153681831442414">
         <div class="_4vm5 _5ay5">
            <ul id="u_0_62">
                 <li class="_3d5d">
                     <a id="u_0_5x" class="_3d5b" role="button" href="#" 
                     data-key="recent">Recent</a>
                 </li>
                 <li class="_3d5d">
                     <a id="u_0_5y" class="_3d5b _-fk" role="button" 
                     href="#" data-key="year_2015">2015</a>
                 </li>
                 <li class="_3d5d">
                     <a id="u_0_5z" class="_3d5b" role="button" href="#" 
                     data-key="year_2014">2014</a>
                 </li>
                 <li class="_3d5d">
                     <a id="u_0_60" class="_3d5b" role="button" href="#" 
                     data-key="year_2013">2013</a>
                  </li>

Aucun commentaire:

Enregistrer un commentaire