getting un expected result in jquery onclick event
i am trying to add class on `on-click`  jquery event for that i am doing 

my html file

    <head>
            <style type="text/css">
                .red{ color:red; }
            </style>
             <script type="text/javascript" src="jquery.js"></script>
            <script type="text/javascript" src="js.js"></script>
        </head>
    <body>
        <ul id="list">
            <li><a href="">1</a></li>
            <li><a href="">2</a></li>
        </ul>
    </body>

javascript file js.js is

    $(document).ready(function(){
         $("li").onclick(function(){ // if i comment this and only add the line billow the all ul>li will red
            $("#list").addClass("red");
        });
    });

when i click on the `li` the color of `li` will become the red the thing makes me confuse that `on-click` i am adding the class `.red` to the `ul` so the both link should be red but on click only the link i clicked  become red

![enter image description here][1]


  [1]: http://i.stack.imgur.com/5xiBW.png
getting un expected result in jquery onclick event
===

i am trying to add class on `on-click`  jquery event for that i am doing 

my html file

    <head>
            <style type="text/css">
                .red{ color:red; }
            </style>
             <script type="text/javascript" src="jquery.js"></script>
            <script type="text/javascript" src="js.js"></script>
        </head>
    <body>
        <ul id="list">
            <li><a href="">1</a></li>
            <li><a href="">2</a></li>
        </ul>
    </body>

javascript file js.js is

    $(document).ready(function(){
         $("li").onclick(function(){ // if i comment this and only add the line billow the all ul>li will red
            $("#list").addClass("red");
        });
    });

when i click on the `li` the color of `li` will become the red the thing makes me confuse that `on-click` i am adding the class `.red` to the `ul` so the both link should be red but on click only the link i clicked  become red

![enter image description here][1]


  [1]: http://i.stack.imgur.com/5xiBW.png