作者JGC18 (JGC)
看板Web_Design
標題[問題] jquery如何自定function傳入物件
時間Mon Dec 2 21:58:40 2013
大家好
最近在摸索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
1F:推 kyork:檢查一下function name 12/02 23:31
2F:推 tomin:可以動喔 只要改一下naming: showMesg showMsg 12/02 23:48