1

I have

<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>

I want to make click on the element that rises when onmouseover="artifactAlt(this,event,2)"is firing, how to do that?

When I am doing $('#body').contents().find('td[art_id="4949"]')[0].click();

i get undefined and nothin happens.

1
  • 4
    What hidden element? I don't see any hidden elements above (no pun). Commented Feb 5, 2017 at 14:13

2 Answers 2

7

You should use .click() method.

function artifactAlt(obj,event,number){
     $(obj).click();
}

function artifactAlt(obj,event,number){
   $(obj).click();
}

$('tr').click(function(){
  alert('tr clicked');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<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;">abcd</td>
      </tr>
   </tbody>
</table>

Sign up to request clarification or add additional context in comments.

Comments

0

You should try jquery trigger's as follows

function artifactAlt(element, event, number) {
  $(element).trigger('click');
}

Usage of trigger('click') will save you one function call as jQuery internally calls trigger for a $().click() function call as pointed out in this post.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.