Skip to content Skip to sidebar Skip to footer

I Created A Dialog, Now How Can I Close It?

I have included a link to my site below for review of the JS in the head section, as well as to allow YOU to see how I set it all up. If you don't want to use the link, I'll also t

Solution 1:

Or you can try this:

<divclass="DoYouHaveADirtBikeForSaleBox"id="DoYouHaveADirtBikeForSaleBox"><h2>Got A Dirt Bike You Want to Sell?</h2><pclass="DirtBikeForSaleBannerButton"><ahref="http://classifieds.your-adrenaline-fix.com/add.php">Yea, Show Me How</a></p><pclass="DirtBikeForSaleBannerButtonNoThanks"><aonclick="javascript:document.getElementById('DoYouHaveADirtBikeForSaleBox').style.visibility='hidden';">Nope, Get This Out of The Way</a></p></div>

Tested on my localhost xD

___________EDITED_______________

Better try this and see if the scroll doesnt show the div again:

<div class="DoYouHaveADirtBikeForSaleBox" id="DoYouHaveADirtBikeForSaleBox">
    <h2>Got A Dirt Bike You Want to Sell?</h2><pclass="DirtBikeForSaleBannerButton"><ahref="http://classifieds.your-adrenaline-fix.com/add.php">Yea, Show Me How</a></p><pclass="DirtBikeForSaleBannerButtonNoThanks"><aonclick="javascript:var div = document.getElementById('DoYouHaveADirtBikeForSaleBox');div.parentNode.removeChild(div);">Nope, Get This Out of The Way</a>

----------------------------UPDATE2---------------------------------

<divid='div2'><divclass="DoYouHaveADirtBikeForSaleBox"id="DoYouHaveADirtBikeForSaleBox"><h2>Got A Dirt Bike You Want to Sell?</h2><pclass="DirtBikeForSaleBannerButton"><ahref="http://classifieds.your-adrenaline-fix.com/add.php">Yea, Show Me How</a></p><pclass="DirtBikeForSaleBannerButtonNoThanks"><aonclick="javascript:var div = document.getElementById('div2');div.parentNode.removeChild(div);">Nope, Get This Out of The Way</a></p></div></div>

Saludos ;)

Solution 2:

You can remove it from the dom using

element.parentNode.removeChild(element);

or you can set the display style of the element to 'none' and then you can play with it and create open-close

Solution 3:

If you're using jquery, you could do it with the "live" method. That will attach event handlers to any new elements that appear on the page even after an ajax request. So if you gave the close bit a class:

<a href="#"class="close_dialog">Nope, Get thisout of the way</a>

You could use this bit if jquery:

$('.close_dialog').live('click', function(){ $('.DoYouHaveADirtBikeForSaleBox').remove(); });

Hope that helps :-)

Solution 4:

you can make button inside div2 and add onClick attribute like this:

<buttononclick="document.getElementById('div2').style.display='none'">Close</button>

Solution 5:

If you don't want to show it again, you could call

document.getElementById('div2').remove();

in the onclick method of the close button.

Or if you might use it again, call

document.getElementById('div2').style.display = 'none';

To call the close function from the href attribute:

<a href="javascript: CloseDialog();">Nope, Get This Out of The Way</a>

Post a Comment for "I Created A Dialog, Now How Can I Close It?"