看板 Ajax 關於我們 聯絡資訊
<html> <head> <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js' type='text/javascript'></script> <script type="text/javascript"> function get_respon(object) { var pre=object.previousSibling.previousSibling; var string=document.getElementById(pre.id).value; $("div#result").append(string); } </script> </head> <body> <input type='text' id='respon' value='response'/> <input type='submit' onclick='get_respon(this);'/></br> <div id="result"></div> </body> </html> -- 我成功了!! 感謝N大指點~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.127.200.211
No:那個..已經有設定id,就直接用id取得element就可以了 09/09 15:30
No:或者你已經用相對位置得到<input>,也可以var string=pre.value 09/09 15:31
wjhong:噢因為我在做類似動態回應 所以input不是固定的 09/09 15:51
wjhong:不能用id直接取得.. 09/09 15:52
s25g5d4:我是建議你套上迴圈一直去找上一個節點 09/09 19:06
s25g5d4:然後每跳到上一個節點就檢查tag name 或其他能辨識的class 09/09 19:07
s25g5d4:之類的 找到就跳出迴圈 09/09 19:07