Open DIV after clicking a Button with Link

8

I would like to know how to create, in CSS3, Javascript or Jquery, a button that, upon clicking it, reveals a DIV on it, and that a new page with target _blank is opened.

I've done enough research, found some things, but nothing concrete. Of course, if possible, I would like something that works across browsers.

-

Update

What I want fits into Diego's response, but one thing I forgot to mention in the question is whether it is possible to open the page link without leaving the current window.

    
asked by anonymous 14.11.2014 / 19:22

2 answers

6

Your question is very broad and can be solved in several ways. Always try to post part of the code you are working so we can better help you.

I'll give you some guidelines.

HTML

HTML should be very simple. Something like:

<button>Clique aqui</button>
<div id="divId" class="hidden"></div>

CSS

The CSS should contain the position of div so that it stays on top of the button. I did not put those styles here. Implement on your own the way it is convenient. I just added the style that hides div .

.hidden{
  display: none;
}

JQuery

The following code performs the action you are looking for.

$('button').on('click',function(){
    $('#divId').show(); // aparece o div
    window.open(seulink,'_blank'); // abre nova janela
});

I hope I have helped.

    
14.11.2014 / 19:35
6

HTML

<div id="escondido">
    Eu irei aparecer
</div>
<a href="http://google.com.br" target="_blank" id="Clique">Clique aqui</a>

CSS

#escondido{
    display:none;
}

JQuery

$( "#Clique" ).click(function() {
  $("#escondido").css("display","block");
});

JSfiddle

    
14.11.2014 / 19:37