2017-12-14 5 views
1

まずHTMLファイルでHTMLファイルおよび出力から入力を得ますか望む。は、どのように私は別のHTMLファイル

第二のHTMLファイル

は、最初のHTMLファイル内にフォーム内の入力にアクセスし、それを3回印刷します。

まずHTML

<!DOCTYPE html> 
<html> 
    <head> 
     <title>First HTML</title> 
    </head> 
    <body> 
     <form> 
      input <input id="silly" type="text" placeholder="Enter something silly"> 
     </form> 
    </body> 
</html> 

セカンドHTML

<!DOCTYPE html> 
    <html> 
     <head> 
     <title>Second HTML</title> 
     </head> 
     <body> 
     <p id="printHere">print the input here 3 times</p> 
     </body> 
    </html> 

私は二HTMLで使用しようとしているjQueryの

$.get('a.html', null, function(text){ 
    alert($(text).find('.silly')); 
}); 
+0

は、あなたは素晴らしいrの –

答えて

0

まずHTML

<!DOCTYPE html> 
<html> 
    <head> 
     <title>First HTML</title> 
    </head> 
    <body> 
     <form> 
      input <input id="silly" type="text" placeholder="Enter something silly" value="aa"> 
     </form> 
    </body> 
</html> 

セカンドHTML

<!DOCTYPE html> 
<html> 
    <head> 
    <title>Second HTML</title> 
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script> 
    <script type="text/javascript"> 
    $.ajax({ 
     url: 'first.html', 
     dataType: 'html', 
     success: function(response) { 
      $(response).find('#silly').clone().appendTo("#printHere"); 
      $(response).find('#silly').clone().appendTo("#printHere"); 
      $(response).find('#silly').clone().appendTo("#printHere"); 
     } 
    }); 
    </script> 
    </head> 
    <body> 
    <p id="printHere">print the input here 3 times</p> 
    </body> 
</html> 

・ホープ、このことができます。おかげ

+0

を渡すmimmicデータに 'cookies'、'ウェブstorage'などを使用することができます!!!!!!!!!!!!!! –

+0

本当に助けてくれたら、投票してください。ありがとう:-) –

+0

私は評判がありませんが、あなたの答えを受け入れました –

関連する問題