Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/403.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Javascript将onclick函数添加到带有此参数的href_Javascript_Onclick_This_Add - Fatal编程技术网

使用Javascript将onclick函数添加到带有此参数的href

使用Javascript将onclick函数添加到带有此参数的href,javascript,onclick,this,add,Javascript,Onclick,This,Add,我有一个像这样的朋友 <a title="my title text" id="6" href="#" class="someclass" onclick="deleteRows(this.parentNode.parentNode)">X</a> 及 搜索了谷歌,但没有发现任何东西。 我该怎么做?您忘记在事件侦听器中调用deleteRows: var a = document.createElement('a'); a.onclick = function() {

我有一个像这样的朋友

<a title="my title text" id="6" href="#" class="someclass" onclick="deleteRows(this.parentNode.parentNode)">X</a>

搜索了谷歌,但没有发现任何东西。
我该怎么做?

您忘记在事件侦听器中调用
deleteRows

var a = document.createElement('a');
a.onclick = function() {
    deleteRows(this.parentNode.parentNode);
};

您忘记在事件侦听器中调用
deleteRows

var a = document.createElement('a');
a.onclick = function() {
    deleteRows(this.parentNode.parentNode);
};
“它不工作”它做什么而不是你期望的?另外,您是否忘了在这些函数中调用
deleteRows
“它的一部分正在工作”它做什么而不是您所期望的?另外,您是否忘记在这些函数中调用
deleteRows
var a = document.createElement('a');
a.onclick = function() {
    deleteRows(this.parentNode.parentNode);
};