2014-10-21 74 views
0

我需要模拟匹配元素(链接)上的自动点击,但我也想在同一行上添加点击行为逻辑,是否有可能?类似下面alert("my Click Behavior");触发点击并链接点击行为

取而代之的是以下内容:

jQ('tbody[groupstring^=";#Emergency;#"] a').click(function(){ 
    jQ(this).parent().parent().parent().next().find('td:contains("Emergency")').each(function(){ 
     jQ(this).html(jQ(this).html().replace(/Emergency/g,"Urgent")); 
    }); 
}) 

我想链上面的点击行为直接到下面:

jQ('tbody[groupstring^=";#Emergency;#"] a').each(function(){ 
    jQ(this).trigger('click').My Click Behavior(); 
}) 
+0

你能否解释一下? – 2014-10-21 21:47:29

+0

@Lajos Arpad看到我对这个问题的更新 – Athapali 2014-10-21 21:49:56

回答

1

这是你如何定义一个点击行为

jQ('tbody[groupstring^=";#Emergency;#"] a').each(function(){ 
    jQ(this).click(function() { 
     //what should happen on click 
    }); 
}) 

这就是你如何定义相同的点击行为r代表许多元素:

jQ('tbody[groupstring^=";#Emergency;#"] a').click(function() { 
    //what should happen on click 
}); 

这是你如何触发点击:

$(mySelector).click();