jQuery无法单击单选按钮单击、单选、按钮、jQuery

2023-09-06 22:12:07 作者:花香洇染

我的代码:

$(document).ready(function(){
    alert("document ready");

    $("input[type=radio]").click(function(event){
        alert("clicked");
    });
});

但是没有显示警报...而且,在控制台上输入时:$(document).ready(function(){ alert("document ready");}) 我收到警报了!这是怎么回事?

But no alert shows up... And, when typing in on the console: $(document).ready(function(){ alert("document ready");}) I get the alert! What is going on here?

推荐答案

我找到了解决方案,它也解释了为什么它在 JSFiddle 中有效.问题是我如何导入 jQuery:我做到了

I found the solution, it explains as well why it does work in JSFiddle. The problem was how I imported jQuery: I did

<script type="text/javascript" src="jQuerylink"/>

它必须是

<script type="text/javascript" src="jQuerylink" ></script>

我不知道为什么会这样,但现在可以了.感谢所有的努力.

I don't know why this is so, but now it works. Thanks for all effort.

 
精彩推荐
图片推荐