Simple JQuery-code but can it be optimized?
Hi,
I've got this in my <head>:
- <script type="text/javascript">
- $jquery(document).ready(function(){
- $jquery(".txt").hide();
- $jquery(".map").hide();
- $jquery("ul li a").click(function () {
- var divname= this.title;
- $jquery("."+divname).slideToggle("slow").siblings().hide("slow");
- });
- });
- </script>
And this as html formatting
- <ul class="knoppen">
- <li><a title="txt" href="#">txt</a></li>
- <li><a title="map" href="#">map</a></li>
- </ul>
- <div>
- <p class="txt">Dummy text goes here</p>
- <p class="map">Maps goes here</p>
- </div>
This works fine. Clicking on txt shows the dummy text, when txt is active and map is clicked, txt goes away. ok.
However I was wondering if things couldn't be more optimized? For example: I would like to see the 'titles' and even if possible the class txt and map.
Maybe it's not possible. But I always like cleaning coding. What's your opinion?