Skip to content

Instantly share code, notes, and snippets.

@ryanbriones
Created April 28, 2009 18:54
Show Gist options
  • Select an option

  • Save ryanbriones/103311 to your computer and use it in GitHub Desktop.

Select an option

Save ryanbriones/103311 to your computer and use it in GitHub Desktop.
<!-- Columbus JS Users group -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>jQuery addClass "selected" test</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(function() {
$('#container .navigation li').click(function() {
$(this).parents('ul:first li').removeClass('selected').end()
.addClass('selected');
console.log($(this).parents('ul:first')[0]);
});
});
</script>
</head>
<body>
<!-- only want one li at a time to have class "selected"-->
<div id="container">
<ul class="navigation">
<li id="momentum-tab"><a href="#momentum"><span>momentum</span></a></li>
<li id="FAQ-tab"><a href="#faqs"><span>faqs</span></a></li>
<li id="registration-tab"><a href="#registration"><span>registration</span></a></li>
<li id="meetings-tab"><a href="#meetings"><span>meetings</span></a></li>
</ul>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment