3.Variable


#1

I have tried to use the target jquery class and i m stuck in a position
i need help.

$(document).ready(function() {
var $target = $('ol li:nth-child(4)');
$('target').fadeOut('fast');

});

The Error: Oops, try again. Did you target the 4th li child of the ordered list?


#2

@ashwin63,

With

var $target = $('ol li:nth-child(4)');

you have created a VARIABLE $target
which now contains a =selection= of HTML-Elements and it's =children= as a jQuery-Object.

You can now point to the =selection= by using the $target VARIABLE
like

 $target.fadeOut('fast');

#3

@ashwin63,

You Browser loads the HTML-document into memory
following the rules of the Document Object Model in short DOM (this is Browser specific)

                   html
                     |
           + - - - - + - - - - +
           |                   |
          head                body
           |                   |
       + - - - +              div
       |       |               |
     title   script            ul
                               |
                   + - - - + - + - - + - - - +
                   |       |         |       |
                  li      li        li      li
                   |
                   ol
                   |
       + - - - + - + - - + - - - +
       |       |         |       |
      li      li        li      li

The ol-HTML-tag is the parent
to the li-HTML-tag children ( you have 4 children, count starts at 1 )


#4

@ashwin63,
Insert this code into your script.js
and play around by removing-or-setting the comment-characters //

// Write your jQuery code on line 3!
$(document).ready(function() {
//    var $target=$('ol li:last-child');
    var $target=$('ol li:nth-child(4)');
//    var $target=$('ol li:contains("chumps")')
//    var $target=$('li:contains("can")')
//    var $target = $("li:last-child")
    $target.fadeOut('fast');

//    $target.fadeOut('fast');
// direct targeting, remove/add // per line
//    $('html').text('=target0=');
//    $('html>body>div>ul>li').text('=target1=');
//    $('html>body>div').text('=target2=');
//    $('li>nth-child(3)').text('=target3=');
//    $('li').text('=target4=');
//    $('ul>li:nth-child(3)').text('=target5=');
//    $('ul li:nth-child(3)').text('=target6=');
//    $('ol li:nth-child(3)').text('=target7=');
//    $('ol').hide(); 
});

#5

Thanks for the solution. it works. but i need a statement of one line that can select the entire line and removes it

But anyways thanks for the solution leohard