boxAに入っている値をappendToを使いboxBに移動させました。
boxBの値をボタンクリック後、alertで表示させたいのですがうまくいきません。
コードが下記になります。
教えていただけると助かります。
html
1<!DOCTYPE html> 2<html lang="ja"> 3 <head> 4 <meta charset="utf-8"> 5 <title></title> 6 7 <!-- jQueryのスタイルシート読み込み --> 8 <link href="" rel="stylesheet"> 9 <!-- jQuery読み込み --> 10 <script src=""></script> 11 </head> 12 <body> 13 <div id = "boxA"> 14 <div class = "aaa">aaa</div> 15 <div class = "bbb">bbb</div> 16 </div> 17 <div id = "boxB"></div> 18 <input type = "submit" id = "button"> 19 <script type="text/javascript" src=""></script> 20 </body> 21</html> 22
javascript
1$(function(){ 2 $(".aaa").click(function(){ 3 $(".aaa").appendTo("#boxB"); 4 }); 5}); 6 7$(function(){ 8 $(".bbb").click(function(){ 9 $(".bbb").appendTo("#boxB"); 10 }); 11}); 12$(function(){ 13 $(".aaa").click(function(){ 14 $(".aaa").appendTo("#boxB"); 15 }); 16}); 17 18$(function(){ 19 $("#button").click(function(){ 20 var delivery = $("#boxB"); 21 alert(delivery); 22 }); 23}); 24
css
1body { text-align: center; 2} 3#boxA { width: 180px; 4 height: 250px; 5 border: 1px solid black; 6 float: left; 7} 8#boxB { width: 180px; 9 height: 250px; 10 border: 1px solid black; 11 float: left;
回答1件
あなたの回答
tips
プレビュー