0

My current code will hide an example form and then will display data taken from other page via json into confirm div.

...other codes

},function(data){
if (data.response==1) {
    $('#example').delay(500).fadeOut();
    $('#confirm').show().html("<form>First name: <input type=\"text\" name=\"name\" value=\" "+ data.name +"  \"><br>Email: <input type=\"text\" name=\"email\" value=\" "+ data.email +" \"></form>"); 
}

...other codes

     <div id="confirm" style="background-color:#FF7800; padding-left:20px; color: white;"></div>

My question is it possible to show/trigger other form and display my data instead of displaying my data inside html() in #confirm id? I think I get the idea how to trigger a hidden form but how do I populated my data inside it?

Thanks in advance

4

1 回答 1

0

是的,将它们包装在 DIV 中(或为表单分配一个 ID):

HTML:

<div id="exampleForm">
  <form> [.. do form here ..] </form>
</div>

<div id="realForm" style="display:none">
  <form> [.. do form here ..] </form>
</div>

jQuery:

$(function() {
  $("#exampleForm").fadeOut();
  $("#realForm").fadeIn();
});
于 2013-06-04T20:39:10.643 回答