Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.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
onload触发器。单击jquery_Jquery_Triggers_Onload - Fatal编程技术网

onload触发器。单击jquery

onload触发器。单击jquery,jquery,triggers,onload,Jquery,Triggers,Onload,下面是我的onload函数 $(document).ready(function () { $('#tops > ul > li > a').click( function () { var showThis = $(this).attr('name'); $('.active').removeClass('active'); $(this).addClass('active'); $('#pane

下面是我的onload函数

$(document).ready(function () {
    $('#tops > ul > li > a').click(
    function () {
        var showThis = $(this).attr('name');
        $('.active').removeClass('active');
        $(this).addClass('active');
        $('#panels > div').hide();
        $('#' + showThis).show();
        $('.single_hide').hide();
        $('#' + showThis + '_edit').show();
        return false;
    });
});
如何按名称触发元素的单击函数

我尝试了
$('myelement')。触发器('click')但它不起作用

$('#myelement').click();
应该这样做

试试这个:

单击事件:

$(“#myElement”)。单击(函数(){

)}

对于触发事件:

$(“YourTriggeredElementId/class”).trigger()

像这样试试

$(document).ready(function () {
   $('#element').on('click' , function () {
         //Do your stuff
   });
});
或者你也可以试一下

$(document).ready(function () {
   $(document).on('click' , '#element' , function () {
         //Do your stuff
   });
});

这是与
$('#myelement')相同的代码哪个OP说不起作用你是对的。我已触发单击,但我触发的元素隐藏在同一个.ready函数中。完全愚蠢。谢谢