Hi Parazival,
You can encapsulate the click event in the Document Ready function, like this-:
<script>
$(document).ready(function() {
$("#table tr").click(function(){
$(this).addClass('selected').siblings().removeClass('selected');
var value=$(this).find('td:first').html();
alert(value);
});
}
</script>
I hope this will work.