I am building a theme selector for maps and want to reflect the currently selected theme.
The code seems to work but never returns the value of the “li” item, it always returns “s-thumbs” for whatever “li” item I click on. I tried using the .closest() method but to no avail.
I’m following this article.
<script language="javascript">
$("ul.s-thumbs").live("click", function(event) {
$("#theme_title").text(
$(this).closest("ul.s-thumbs li").attr("class")
);
});
</script>
<div id="theme">You have selected the <div id="theme_title"></div> Theme</div>
<div class="container_16" id="themebg">
<!--<div class="grid_1"> <a href="" "img" src="/styles/image/leftarrow.png" id="leftarrow" alt=""/></div>-->
<div class="grid_16 slider-wrapper">
<ul class="s-thumbs">
<li class="Default"> <a href="javascript:setRoadmap()"><img src="/styles/image/thumbs/default.png" alt="" /></a>Default</li>
<li class="Hatchery"> <a href="javascript:setGreen()"><img src="/styles/image/thumbs/hatchery.png" alt="" /></a>Hatchery</li>
</ul>
</div>
Demo link: http://jsfiddle.net/ChaseWest/w2tCE/4/