JS 框架使用及迁移(二)B、方法部分1、方法调用Prototype:$j(#link).click(function(event){console.log(th
JS 框架使用及迁移(二)
B、方法部分
1、方法调用
Prototype:
$j('#link').click(function(event){console.log(this); //输出空, event.target 才是 html 元素对象console.log($j(event.target).attr('href')); //用 $j 转化成为 jQuery 对象才能调用 attr 方法event.preventDefault();});在如上代码中,点击了链接之后,不会被重定向到目标页面。而是执行完输出之后直接停止。
