[問題] jquery如何自定function傳入物件

看板Web_Design作者 (JGC)時間12年前 (2013/12/02 21:58), 編輯推噓2(200)
留言2則, 2人參與, 最新討論串1/1
大家好 最近在摸索jquery 由於想要把一些功能獨立出來寫成function 我在 http://www.darkthread.net/MiniJQueryLab/ 想要測試一下,底下這段錯誤程式碼 [html] <table border="1"> <tr> <td id="td1">1221</td> <tr> </table> [script] function showMesg(td)//我知道不能這樣寫 { alert(td.text()); } $(document).ready(function() { var tmpTd=$("#td1"); alert(tmpTd.text());//show 1221 showMsg(tmpTd); }); 希望把某一個元素select出來後,丟給一個變數 再把這一個變數丟進自定function 再call自定function 不知道該如何下手,請指點我一點方向 感謝^^ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 175.182.168.174

12/02 23:31, , 1F
檢查一下function name
12/02 23:31, 1F

12/02 23:48, , 2F
可以動喔 只要改一下naming: showMesg showMsg
12/02 23:48, 2F
文章代碼(AID): #1Id98JkA (Web_Design)