Javascript 单击所选类别标记内的第一个onclick函数

Javascript 单击所选类别标记内的第一个onclick函数,javascript,c#,jquery,asp.net,Javascript,C#,Jquery,Asp.net,我是新来的。。。让我知道如何单击这个div中的第一个onclick。请注意,如果使用$(“.giornoweekcorrente”),我将选择div的整个内部,但我的问题是,如何单击函数visualizezaevento。。。通过“giornoweekcorrente”课程 请看一下这张图片,以便理解 谢谢你的帮助 像这样试试。希望这有帮助 $('.giornoweekcorrente a:first').click(); 像这样试试。希望这有帮助 $('.giornoweekcorrent

我是新来的。。。让我知道如何单击这个div中的第一个onclick。请注意,如果使用$(“.giornoweekcorrente”),我将选择div的整个内部,但我的问题是,如何单击函数visualizezaevento。。。通过“giornoweekcorrente”课程

请看一下这张图片,以便理解


谢谢你的帮助

像这样试试。希望这有帮助

$('.giornoweekcorrente a:first').click();

像这样试试。希望这有帮助

$('.giornoweekcorrente a:first').click();
可能的解决方法:

// get the first anchor child of the element and trigger the desired event:
$('.giornoweekcorrente').on('click', function(){
    $('a', this).first().trigger('click');
});
可能的解决方法:

// get the first anchor child of the element and trigger the desired event:
$('.giornoweekcorrente').on('click', function(){
    $('a', this).first().trigger('click');
});
找到你所在部门的孩子,找到第一个孩子

见:

找到你所在部门的孩子,找到第一个孩子


请参阅:

您的锚定标签具有id为什么不使用该id:

$("#lente_click_gio").click();

你的锚定标签有一个id为什么不使用它:

$("#lente_click_gio").click();

Markus,您可能希望直接将“onclick”附加到id为“lente_click_gio”的元素。可以使用以下代码执行此操作:

$(document).ready(function(){
    $("#lente_click_gio").on('click',function(){
       //Your code here .. Call visualizzaEvento
    });
});
$("#lente_click_gio").click(); /* Generate a click event on the element with the ID lente_click_gio */
但这只会附加click事件和回调。相反,如果要在附加函数的锚元素上触发单击事件,请尝试以下代码:

$(document).ready(function(){
    $("#lente_click_gio").on('click',function(){
       //Your code here .. Call visualizzaEvento
    });
});
$("#lente_click_gio").click(); /* Generate a click event on the element with the ID lente_click_gio */

这将触发该元素上的单击事件。希望这会有所帮助。

Markus,您可能希望直接将“onclick”附加到id为“lente\u click\u gio”的元素。可以使用以下代码执行此操作:

$(document).ready(function(){
    $("#lente_click_gio").on('click',function(){
       //Your code here .. Call visualizzaEvento
    });
});
$("#lente_click_gio").click(); /* Generate a click event on the element with the ID lente_click_gio */
但这只会附加click事件和回调。相反,如果要在附加函数的锚元素上触发单击事件,请尝试以下代码:

$(document).ready(function(){
    $("#lente_click_gio").on('click',function(){
       //Your code here .. Call visualizzaEvento
    });
});
$("#lente_click_gio").click(); /* Generate a click event on the element with the ID lente_click_gio */

这将触发该元素上的单击事件。希望这会有所帮助。

谢谢!这很有效!如果我把第二个工作放在第二个onclick上,是不是?为了真诚。再次感谢!使用
:第n个子项(n)
,其中
n
是目标的编号child@MarkusWerner:您需要使用第n个子项(2)秒。读一下,谢谢!这很有效!如果我把第二个工作放在第二个onclick上,是不是?为了真诚。再次感谢!使用
:第n个子项(n)
,其中
n
是目标的编号child@MarkusWerner:您需要使用第n个子项(2)秒。读一读,我投票结束这个问题,因为它离题了。请不要发布截图,并期望人们通过查看图像和在图像中写下代码来解决您的问题,以供测试!通过编写代码来分享代码的相关部分。我将投票结束这个问题,作为离题。请不要发布截图,并期望人们通过查看图像和在图像中写下代码来解决您的问题,以供测试!通过编写代码来共享代码的相关部分。