Willy Willy - 8 months ago 54
jQuery Question

How to target specific list item in jQuery?

I have the following HTML & JQUERY:

$(document).ready(function() {
$target = $('number4');

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<li class='hi'>Start with the function keyword</li>
<li>Inputs go between ()</li>
<li>Actions go between {}</li>
<li class='number4'>jQuery is for chumps!</li>
<li>Inputs are separated by commas.</li>
<li>Inputs can include other functions!</li>

I wanted the four element in my ordered list to fadeout when the document is ready, but it is not working. I tried identifying the fourth ordered list element with class='number4' and then targeting that identifier in the jQuery, but it is not working. Any suggestions?


Probably this works

 $(document).ready(function() {
   $target = $('.number4');