Since few hours I tried to make a script which will show a div when the window.location.hash is set up. When the page is ready the script works but when I try to call it with jQuery event .click() it doesnt work.
The code:
var bodyHeight = $('body').height();
$(asd);
function asd() {
locationHash = window.location.hash.replace(/^#!/, '');
if(locationHash != "") {
$('div#bgLayer').css({
'height': bodyHeight,
'display': 'block'
});
$('div#feedBack').css('display', 'block');
$('div#bgLayer, div#feedBackRight').click(function() {
var clientName = "";
var clientEmail = "";
var clientWebsite = "";
var clientImage = "";
var clientFeedBack = "";
$('div#bgLayer').css('display', 'none');
$('div#feedBack').css('display', 'none');
$('div#feedBacks').css('display', 'block');
$('div#feedBackForm').css('display', 'none');
$('a#showFeedBacks').css('font-weight', 'bold');
$('h3#clientsAboutUs').css('display', 'inline-block');
$('h3#addFeedBackAboutUs').css('display', 'none');
$('div.pages').css('display', 'block');
$('a#addFeedBack').css('font-weight', 'normal');
window.location.hash = '!';
});
if(locationHash == 'addFeedBack') {
$('div#feedBacks').css('display', 'none');
$('h3#clientsAboutUs').css('display', 'none');
$('h3#addFeedBackAboutUs').css('display', 'inline-block');
$('div.pages').css('display', 'none');
$('div#feedBackForm').css('display', 'block');
$('a#showFeedBacks').css('font-weight', 'normal');
$('a#addFeedBack').css('font-weight', 'bold');
$('input#submitFeedBack').attr('disabled', 'disabled');
}
else if(locationHash == 'showFeedBacks') {
$('div#feedBackForm').css('display', 'none');
$('h3#clientsAboutUs').css('display', 'inline-block');
$('h3#addFeedBackAboutUs').css('display', 'none');
$('div.pages').css('display', 'block');
$('div#feedBacks').css('display', 'block');
$('a#addFeedBack').css('font-weight', 'normal');
$('a#showFeedBacks').css('font-weight', 'bold');
}
}
}
$('#addFeedBack-page').click(asd);
The #addFeedBack-page is:
<a href="#!addFeedBack" id="addFeedBack-page" class="buttons" title="Click me">Click me</a>
So how to make it right?
Best regards, George!