pass this to functon by event   Leave a comment

<html>
<head>
<script type=”text/javascript” src=”jquery.js”></script>
<script type=”text/javascript”>
function f(obj){
var result  = $(obj).text();
alert(result);
}
</script>
</head>
<body>
<span onclick=”f(this)”>test001</span>
<span onclick=”f(this)”>test002</span>
</body>
</html>

这里的this为DOM元素, 再变为jquery元素,然后进行相关操作。

Posted 2011年04月10日 by gw8310 in javascript

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: