Skip to main content

Posts

Showing posts with the label hash

jQuery IF var = value or #id clicked

I have the .live aspect working now so if links are clicked, my function is executed, but I'm trying to figure out how include an option for a direct link to the content as well. Something like this: $(showDiv).is('shipping-timeline') or $("#inm_if_hc_shipping_timeline").live('click', function() { [code to show and hide divs] }); showDiv contains the value that identifies the proper id, extracted from the URL. My Question: How do I construct the IF statement to execute if either case is true? Can anyone help? Thanks! UPDATE: So I took the IF parts from Graydot's answer and applied it to my code and here is a more complete example of what it looks like now: $("#inm_if_hc_faq").bind('click', function(e) { if(showDiv == 'faq') { // prevent default behavior e.preventDefault(); $("#inm_if_hc_content_faq").show("slow"); $("#inm_if