Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.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
Jquery点击td_Jquery_Html - Fatal编程技术网

Jquery点击td

Jquery点击td,jquery,html,Jquery,Html,我需要点击td标签 <table width="60" height="60" cellpadding="0" cellspacing="0" border="0" style="float: left; margin: 1px" background="images/data/source_red.gif"> <tbody> <tr> <td act1="7" act3="8" store="true" art_

我需要点击td标签

<table width="60" height="60" cellpadding="0" 
cellspacing="0" border="0" style="float: left; margin: 1px" 
background="images/data/source_red.gif">
   <tbody>
      <tr>
         <td act1="7" act3="8" store="true" art_id="4949" cnt="1" div_id="AA_4949" 
         onmouseover="artifactAlt(this,event,2)" 
         onmouseout="artifactAlt(this,event,0)" 
         valign="bottom" 
         style="background-image: url(&quot;images/d.gif&quot;); cursor: pointer;">&nbsp;</td>
      </tr>
   </tbody>
</table>


您是如何通过jQuery找到它的?

您的意思是要使用jQuery单击
元素吗?如果是:

将id添加到

你可以用

如果变量中有
art\u id=“4949”

然后要单击元素,可以使用
get(index)
检索底层DOM元素,然后触发本机
click()


注意:我建议使用
data-*
前缀自定义属性来存储元素中的任意数据。

不完全确定您想要实现什么-但对所有td属性使用HTML5的数据属性-然后将click事件绑定到td onclick和console是一件容易的事情。记录那是td

$(文档).ready(函数(){
$('td')。单击(函数(){
var id=$(this.attr('data-art_id');
console.log('art_id='+id);
});
});

td1
td2

你能详细说明一下吗?贫穷的question@Satpal例如,在html中,我有太多其他内容,通过jquery,我只想通过唯一符号查找可能是“art_id=“4949”。然后单击该td,其中包含art_id=“4949”。
<td id="clickme" act1="7" act3="8" store="true" art_id="4949" cnt="1" div_id="AA_4949" onmouseover="artifactAlt(this,event,2)" onmouseout="artifactAlt(this,event,0)"  valign="bottom" style="background-image: url(&quot;images/d.gif&quot;); cursor: pointer;">&nbsp;</td>
$("#clickme").click
var td = $('td[art_id="4949"]');
var art_id="4949";
var td = $('td[art_id="' + art_id +'"]');
td.get(0).click();