html - How can I get a jQuery event to fire on a direct link to http://www.website.com/#id? -


trying figure out how can jquery detect hyperlink referencing unique id on page. want load event not when element clicked on page, if direct links page using unique #id assigned #div.

update:

ok, have far , it’s not firing.

    function opencontact() {         $("#first-name-check").hide();         $("#last-name-check").hide();         $("#phone-number-check").hide();         $("#email-address-check").hide();         $("#customer-message-check").hide();         $("#send").button("disable");         $("#email-form").dialog("open");     }      $(".email").click(opencontact);      var hash = window.location.hash.substring(1);         alert(hash);         if (hash == "contact") {             opencontact();         } 

alert returning correct #hash don’t know what’s wrong.

dialog initialized this:

   $(function() {         $("#email-form").dialog({             autoopen: false,             resizable: false,             draggable: false,             closeonescape: false,             height: 600,             width: 540,             modal: true,             buttons: {                 "send joe message": {                     text: "send joe message",                     id: "send",                     click: function() {                         $.post("email.php", $(this).find('input, textarea').serialize());                         $(this).find('input, textarea').val("");                         $(this).dialog("close");                     },                 },                 cancel: function() {                     $(this).find('input, textarea').val("");                     $(this).dialog("close");                 }             }         });      }); 

you this:

$(document).ready(function() {   // attach click handlers , set dialog here..   if(window.location.hash.length > 1) {     switch(window.location.hash) {       case '#contact':         $('.email').click();         break;       case '#anyotheridyouvegot':         $('.classoftheelementtobeclickedon').click();         break;     }   } }); 

this check if there hash in url @ page load , trigger click on element id depending on hash value.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -