作者nov17th75 (oxygenic)
看板Ajax
标题[问题] 在select物件中增加onchange attribute...
时间Wed Dec 2 23:54:55 2009
如标题
我想在 html select 当中增加 onchange attribute
原本用的方法是
<script type="text/javascript">
var type = document.createElement( "select" );
type.onchange = "函式名称( 参数 )";
</script>
但没有反应
是否这样的方法有错误呢?
先感谢回答!
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.113.141.156
1F:→ emn178:不要引号 12/03 09:25
2F:→ grence:type.onchange = yourFunctionName;//without () 12/03 18:54
3F:→ nov17th75:e大的方法可能我漏掉了甚麽,好像还是行不通 12/03 22:39
4F:→ nov17th75:也想请问grence那该如何传参数给函式呢?谢谢一二楼两位! 12/03 22:41
5F:→ grence:arguments; yourFn(){alert(arguments[0])} 12/03 23:11
6F:→ grence:是要传参数啊…可以挂自订属性在type上 然後用this.属性 抓 12/03 23:14
7F:→ grence:或是函数外再包一层函数…看你要传的东西是什麽 12/03 23:16