javascript - Closing Div With Button -


i'm trying open div when user clicks link. did using leanmodal. however, have question div.

i want user click button (or link), , fill form. @ bottom of opened div, there 2 buttons. confirm (or submit) cancel. , both of these buttons close div , submit button submits form, while cancel button cancels form.

how can close div , check whether user clicked submit or cancel?

thank much.

here's copy/paste code leanmodal example. know doesn't show anything, because leanmodal not included.

basically, have anchor , div in body. anchor shows div when it's clicked.

here's code piece that:

<a id="go" rel="leanmodal" name="test" href="#test">basic</a>  <div id="test">  <input type="button" value="das" /> </div> 

edit: part added after:

<script type="text/javascript">     $(function() {         $("a#go").leanmodal({ closebutton: ".popbutton" });     });      $('.popbutton').click(function()     {         id = $(this).attr('id'));          if(id == "send")         {             alert("send");         }     });  </script> 

have tried using standard jquery?

for sample simple as:

$("#go").click(function(){     $("#test").slidetoggle(500); //500 being time animate view }); 

heres api documentation jquery slidetoggle

heres working example :)

slider example

edit:

for request answer still quite simple, jquery has of functionality needed anything.

$("#go").click(function(){     $("#test").slidedown(500); //500 being time animate view }); $(".fbutton").click(function(){     $("#test").slideup(500); //500 being time animate view }); 

heres api documentation jquery slidedown jquery slideup

example:

sliderdown , sliderup example

edit 2:

still quite simple, if condition , adding id's buttons :)

$("#go").click(function(){     $("#test").slidedown(500); //500 being time animate view }); $(".fbutton").click(function(){     if($(this).attr('id') == "close")//attr attribute of tag, here id     {         alert("close clicked!");     }     else if($(this).attr('id') == "confirm")//attr attribute of tag, here id     {         alert("confirm clicked!");     }     $("#test").slideup(500); //500 being time animate view }); 

i have put if conditions here instead of adding click functions individually, maintain browser compatibility i.e. browsers dont wait alert go away before animating.

heres api documentation jquery attr

example :

slidedown , slideup alert example


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -