Need Idea which I don't know how to describe
Hi,
I think i have a simple problem, I want to do something like that:
- <script type="text/javascript">
- $(function()
- {
- $("#kk[x]").click(function(event)
- {
- event.preventDefault();
- alert(x);
- });
- });
- </script>
- <a href="#" id="kk[1]">First</a>
- <a href="#" id="kk[2]">Second</a>
I want to make it to show me "1" when i click in First and "2" when i click in Second. Is it possible? I try on several diffrent ways but nothing worked as i would like it to. Sorry for my english, and i don't know if described it well enough to understand but i'll be appreacitive for every help here on forum or even though links to proper documentation or even examples. Thanks!
Update:
I done it that way:
- <html>
- <head>
- <title>As dsd</title>
- <link type="text/css" href="css/black-tie/jquery-ui-1.7.2.custom.css" rel="stylesheet" />
- <!--<link type="text/css" href="css/ui-lightness/jquery-ui-1.7.2.custom.css" rel="stylesheet" />-->
- <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
- <script type="text/javascript" src="js/jquery-ui-1.7.2.custom.min.js"></script>
- <style type="text/css">
- .selected
- {
- color:green;
- }
- </style>
- <script type="text/javascript">
- $(function()
- {
- var tt;
- $("a#kk").click(function(event)
- {
- var index = $("a#kk").index(this);
- var alf=["a", "b", "c", "d", "e", "f", "g", "h"];
- alert($("a#kk").index(this));
- $("a#kk." + alf[index]).addClass("selected");
- });
- });
- </script>
- </head>
- <body>
- <a href="#" id="kk" class="a">First</a>
- <a href="#" id="kk" class="b">Second</a>
- <a href="#" id="kk" class="c">Third</a>
- <a href="#" id="kk" class="d">Fourth</a>
- </body></html>
but i thin this instance sucks ;/ what do you think?