help with jquery

0

I have the following problem:

<div class="slider">
    <div id="slides" id="banner">
        <img class="slide active" src="img/slide1.png">
        <img class="slide" src="img/slide1.png">
        <img class="slide" src="img/slide1.png">
    </div>
    <a href="#" id="banner-prev" class="flecha-banner anterior"><span class="fa fa-chevron-left"></span></a>
    <a href="#" id="banner-next" class="flecha-banner siguiente"><span class="fa fa-chevron-right"></span></a>
</div>

and in a js I have this:

 $(document).ready(function(){
  var banner = {
    padre: $('#banner'),
    numeroSlides : $('#banner').children('.slide').length
  }
  console.log(banner.numeroSlides);
});

When debugging in the console log, I get 0

and it does not make sense, because I'm saying I want all the children of the element #banner with the class .slide, and that I calculate the number.

If you help me I would appreciate it .. thanks in advance

I have the latest version of jquery 3.3.1

    
asked by ragnamex 18.11.2018 в 05:41
source

1 answer

1

Good morning. Apparently your Javascript code is correct. The only mistake you have is that you have placed two ID property to the container div:

<div id="slides" id="banner"> 

That is incorrect, please delete id="slides" and it should work. Greetings

    
answered by 18.11.2018 / 06:01
source