jQuery: .click() and execute function -
since few hours tried make script show div when window.location.hash set up. when page ready script works when try call jquery event .click() 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 make right?
best regards, george!
var bodyheight = $('body').height(); $(document).ready(function () { asd(); $('#addfeedback-page').click(function(){ 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'); } } }
Comments
Post a Comment