Jquery点击td
我需要点击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_
<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("images/d.gif"); cursor: pointer;"> </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("images/d.gif"); cursor: pointer;"> </td>
$("#clickme").click
var td = $('td[art_id="4949"]');
var art_id="4949";
var td = $('td[art_id="' + art_id +'"]');
td.get(0).click();