Hi there,
i've a little issue related to siblings in jquery,
i'm using sibling to deselect the previous selected link after
clicking on the new link, but it's now working,
please let me know where i'm missing.

here is the HTML code:
--------------------------------------------------------------------------------------------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
        ul{list-style-type:none; border:1px solid #ccc; width:200px; padding:
0;}
        ul li{border-bottom:1px dotted #ccc;}
        ul li a{display:block; padding:5px; color:#444; text-decoration:none}
        ul li a:hover{background:#CF0}
        .bg{background:#CF0}
</style>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
        $(document).ready(function(){
                $("a").click(function(){
                        $(this).toggleClass("bg");
                        $(this).siblings("a").removeClass("bg");


                });
        });
</script>
</head>

<body>
<ul>
        <li><a href="#">Link 1</a></li>
    <li><a href="#">Link 2</a></li>
    <li><a href="#">Link 3</a></li>
    <li><a href="#">Link 4</a></li>
    <li><a href="#">Link 5</a></li>
</ul>
</body>
</html>

----------------------------------------------------------------------------------------------------------------------------------------------------

Reply via email to