jquery怎么自动触发radio的点击事件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jquery怎么自动触发radio的点击事件相关的知识,希望对你有一定的参考价值。

给对应的radio加个类名或者Id,然后在在需要触发的函数里写上对应radio的点击事件,如在页面加载完成时点击:

<input type="radio" class="radiobox" />

$(document).ready(function()
    $(".radiobox").click();
);

参考技术A

给对应的radio加个类名或者Id,然后在在需要触发的函数里写上对应radio的点击事件,如在页面加载完成时点击:

<inputtype="radio"class="radiobox"/>&#36;(document).ready(function()

&#36;(".radiobox").click();

);

<script type="text/javascript">

// 两秒后模拟点击

setTimeout(function()

// IE

if(document.all)

document.getElementById("clickMe").click();

// 其它浏览器

else

var e = document.createEvent("MouseEvents");

e.initEvent("click", true, true);

document.getElementById("clickMe").dispatchEvent(e);

, 2000);

</script>

<a href="#" id="clickMe" onclick="alert('clicked');">link</a>

以上是关于jquery怎么自动触发radio的点击事件的主要内容,如果未能解决你的问题,请参考以下文章