-3
  <ul id="playlist">
        <div class="col-lg-3 text-center grid-list" id="grid-list">
            <div>
                <img src="<?php the_post_thumbnail_url(); ?>" class="grid-img">
            </div>
                <li><?php the_title();?></li>
        </div>
       <ul>

i used this code to get the initial info

initList($('#playlist li:first-child'));

but since the client decided to make it grid list i dont know how to revised it when it is inside a div

XYZ
  • 4,450
  • 2
  • 15
  • 31
  • 6
    Invalid Markup. `ul > div > li`. – Tushar Jan 27 '17 at 05:01
  • 2
    Not related to question. Just for info .Dont make div as direct child of
      . http://stackoverflow.com/questions/11755628/can-i-use-div-as-a-direct-child-of-ul
    – XYZ Jan 27 '17 at 05:04
  • Possible duplicate of [jQuery first child of "this"](http://stackoverflow.com/questions/2275702/jquery-first-child-of-this) – Slartibartfast Jan 27 '17 at 05:04

1 Answers1

0

Your problem is that the li is not the first child of #playlist. You want :first instead.

shadymoses
  • 3,273
  • 1
  • 19
  • 21
  • oh thanks i thought it was its child so i just omit it hte the child instead thaks for the help – Richard Mark Bonifacio Jan 27 '17 at 05:21
  • It is a child, it's just not the first child. The ```:first-child``` selector only matches for the first child of any element. The jQuery ```:first``` selector acts more like ```:first-of-type``` from the css spec. – shadymoses Jan 27 '17 at 05:24
  • if thats the case then this would not work anymore var next = $('#playlist li.active').next(); – Richard Mark Bonifacio Jan 27 '17 at 05:35
  • That would get whatever element is the next sibling of ```li.active```. That would work just fine if that's what you're trying to do. – shadymoses Jan 27 '17 at 14:13