0

ther8.com there is a button on the top right as Login when I click on it, it shows a popup box.

I need to create a similar button and tried the below manner

$( "#domylogin" ).click(function() {
    $( "#fancybox-overlay" ).show( "slow" );
});

and the above didn't work.

Also, in Chrome inspector I tried remove div name and class name for the Login element and tried in the below way

<a href="#popup2">Login</a> and found this still works. I can't determine how this is working. I need to create another login button in same page but different area which should display the same popup but its not displaying. Can anyone give me an idea how to fix it?

I created a <span id="domylogin">Login</span> and I want this to work.

I also tried as But this too didn't work

<script type="text/javascript">
    function anotherlogin() {
        div = document.getElementById('fancybox-overlay');
        div.style.display = "block";
    }
    document.getElementById('domyligin').onclick
    {
        anotherlogin();
    }
</script>

Update1:

I am thinking the #fancybox-overlay and its content is loading on request using AJAX but I am not much sure, can anyone open www.ther8.com and click on the login button on the top and see how the popup is being displayed.

1
  • 1
    See Adil's answer. But you also have a typo in domylogin near the bottom. (Note, Adil's answer has the same typo, but at least it's used consistently throughout.) Commented Jan 3, 2014 at 7:42

2 Answers 2

3

You need to assign the javascript function to onclick for binding handler.

Live Demo

document.getElementById('domyligin').onclick = function()
{
    anotherlogin();
}

Edit

Make sure that the elements are added to DOM before you bind event to them, you can put your script just before closing tag of body.

Sign up to request clarification or add additional context in comments.

2 Comments

No, didn't work. Can you please try it in console of www.ther8.com and see.
Make sure that the elements are added to DOM before you bind event to them, you can put your script just before closing tag of body.
0

Do you include jQuery and fancybox library ?

From your post, it seems using those library.

2 Comments

This was posted as an answer, but it does not attempt to answer the question. It should possibly be a comment.
I am thinking fancybox library is loading on click.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.