I have a snippet of HTML that when a link is clicked, the div content becomes the linked div content. The first function works fine. It is the second click on #hidelink that jQuery doesn't seem to respond. What am I missing here?
<div id="right">
<div id='titletext'><p>||||||||||||||</p></div>
<div id='presentation'></div>
<div class='hidethisdiv'>
<div id ="years">
<h4><a id='resourceslink' href='#resources'>2010 Presentations</a></h4>
</div>
<div id='resources'>
<h4><a id='resourceslink' href='#resources'>2010 Presentations</a></h4>
<p><a id='hidelink' href='#years'>«--back</a></p>
</div>
</div>
</div>
<script type="text/javascript">// <![CDATA[
$('#mainmenu').fadeIn(2000, function() {
// Animation complete.
});
$('#presentation').html($('#years').html());
$( function() {
$("#resourceslink").click(
function () {
$('#presentation').html($('#resources').html());
}
);
$("#hidelink").click(
function (){
$('#presentation').html($('#years').html());
}
);
//just add more divs like resources and a hidelink for new conferences
});
</script>
$(function() { ...chunk has not initiated. Try to remove the$(function ()part and just run those$("resourceslink).click(...). If you need to wrap, try($(function() {...})()Hope that helps. Also,idcannot be assigned multiple times, useclassinstead.