JavaScript Click event based on eq() selection

I'm trying to fire a click event based on an element I get using eq().

I have three elements with the same class name: ag-list-item.

<!-- item one -->
<div ag-repeat="" class="ag-list-item ag-not-dragging">
    <span>
        <span class="ag-visible-icons">
        </span>

        <span>Avg. Yield (bu/ac)</span>
    </span>
</div>
<!-- /item one -->

<!-- item two -->
<div ag-repeat="" class="ag-list-item ag-not-dragging">
    <span>
        <span class="ag-visible-icons">
        </span>

        <span>Total Average</span>
    </span>
</div>
<!-- /item two -->

<!-- item three -->
<div ag-repeat="" class="ag-list-item ag-not-dragging">
    <span>
        <span class="ag-visible-icons">
        </span>

        <span>Crop Type</span>
    </span>
</div>
<!-- /item three --> 

I'm trying to fire a click event on the nested span element of a specific ag-list-item element. I've used :first to click the first, but would like to target at a specific index (i.e. first, ,second, third, etc.)

// click all with .ag-list-item class
$('.ag-list-item span span').click()

// click first item in set
$('.ag-list-item:first span span').click()

// try to only click the second item in the set

// get second
var el = $('.ag-list-item').children('span span').eq(2);

// click second item in set
$(el).click();

Please help!

Answer:1

Local variables in functions seem to persist after the function is called. Is this always the case? How does this work? // example 1 function Obj(str) { this.show = function () { ...

Local variables in functions seem to persist after the function is called. Is this always the case? How does this work? // example 1 function Obj(str) { this.show = function () { ...

  1. variables lifetime javascript

I Have 2 differents AngularJs modules : a widgetContainer and a widget. A widget can be displayed as an independant application or be included into a widgetContainer. A widgetContainer contains 0-N ...

I Have 2 differents AngularJs modules : a widgetContainer and a widget. A widget can be displayed as an independant application or be included into a widgetContainer. A widgetContainer contains 0-N ...

  1. angularjs nested modules
  2. angularjs nested modules example

So I am building a Chrome DevTools extension that inspects binary traffic on particular website. Requests on site are made with responseType = "blob". Now when I get request with chrome.devtools....

So I am building a Chrome DevTools extension that inspects binary traffic on particular website. Requests on site are made with responseType = "blob". Now when I get request with chrome.devtools....

  1. javascript reading binary files
  2. javascript reading binary data
  3. js reading binary file

The solution to this problem might be very trivial but its got me banging my head on walls! Bootstrap's js files are not loading on my web page for some reason. I simplified the page to the bare ...

The solution to this problem might be very trivial but its got me banging my head on walls! Bootstrap's js files are not loading on my web page for some reason. I simplified the page to the bare ...

  1. bootstrap loading bar
  2. bootstrap loading mask
  3. bootstrap loading placeholder
  4. bootstrap loading buttons
  5. bootstrap loading spinner modal
  6. bootstrap loading overlay example
  7. bootstrap loading spinner on button click
  8. bootstrap loading button on click
  9. bootstrap loading spinner overlay example
  10. bootstrap loading spinner modal example
  11. bootstrap loading dots
  12. bootstrap loading progress bar
  13. bootstrap loading spinner not showing
  14. bootstrap loading bar circle
  15. bootstrap loading component
  16. bootstrap loading spinner css
  17. bootstrap loading spinner in center
  18. bootstrap loading example
  19. bootstrap loading spinner react
  20. bootstrap loading full screen