javascript:void,0和onclick=fn

  今天在写代码中遇到一个这样的问题。关于点击在html中添加点击事件,顺便把this对象通过参数传过去。

<a href='#' \>查看详情</a>    <a href='javascript:markResolve(this);' \>标记解决</a>    <a href='#' \>同步</a>

但是这样写传过去的对象不是我想要的对象,该对象中数据个数为0,没有任何内容。然后找找资料,这样写就可以了

<a href='#' \>查看详情</a>    <a href='javascript:void(0);' onclick='markResolve(this);'\>标记解决</a>    <a href='#' \>同步</a>

JS代码如下:

JQuery:

1 function markResolve(o) {
2     var text = $(o).parent().html();
3     alert(text);
4 }

JavaScript:

1 function markResolve(o) {
2     alert(o.parentNode.innerHTML);
3 }