*New question following suggestions:
HTML head contains:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script type="text/javascript" src="myscript.js"></script>
Here is my HTML:
<div id="sidebar">
<table id="table1">
<tr>
<th>Table</th>
</tr>
<tr>
<td>
<a href="javascript:;" rel="img1">Link1</a>
</td>
<td>
<a a href="javascript:;" rel="img2">Link2</a>
</td>
</tr>
</table>
</div>
<div id="box">
<img src="http://icons.iconarchive.com/icons/artdesigner/emoticons-2/256/cant-believe-it-icon.png" id="img1" class="images"/>
<img src="http://icons.iconarchive.com/icons/artdesigner/emoticons-2/256/too-much-icon.png" id="img2" class="images"/>
</div>
And my CSS:
#sidebar {
display: inline-block;
height: auto;
width: auto;
font-family: Garamond;
font-size: large;
}
#table1 {
border: 1px solid black;
text-align: center;
}
#table1 th {
border: 1px solid black;
}
#table1 td {
border: 1px solid black;
}
#box {
position: relative;
height: 200px;
width: 1200px;
}
.images {
display:none;
position: absolute;
top: 0px;
left: 0px;
}
And my Javascript:
$('a').click(function(){
imgid = $(this).attr('rel');
$('a').removeClass('active');
$(this).addClass('active');
$('img').hide();
$('#'+imgid).fadeIn('slow');
});
This should mean that when the Link1 is clicked, the first image appears and when the Link 2 is clicked, the second image appears and the first goes away (the images are on top of each other in CSS). However, when either of the two are clicked, nothing happens. Any suggestions why this may be the case?