Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/365.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 获取表元素_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript 获取表元素

Javascript 获取表元素,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我想为HTML表中的特定行获取一个元素 这是我的桌子 <tr class="inner2-top"> </tr> 我使用以下HTML运行以下代码: <td class="status1"><img src="images/cross.png" href="#" onclick="removeRoute()" width="12" height="12" alt="cross"> 在onclick函数中,如果将此作为参数传递,则可

我想为HTML表中的特定行获取一个元素

这是我的桌子

    <tr class="inner2-top">
    </tr>
我使用以下HTML运行以下代码:

<td class="status1"><img src="images/cross.png" href="#" onclick="removeRoute()" width="12" height="12" alt="cross">

onclick
函数中,如果将
作为参数传递,则可以很容易地隔离实例

<img  onclick="removeRoute(this)">

元素具有类“ddu.orl”,但是,您尝试选择它时出现了“ddu orl”小格式错误。不是问题。
<td class="status1"><img src="images/cross.png" href="#" onclick="removeRoute()" width="12" height="12" alt="cross">
<img  onclick="removeRoute(this)">
function removeRoute(elem) { 
  var objectId = $(elem).closest('tr').find(".ddu-orl").text();
  console.log(objectId);
}