手风琴标题中的无线电输入问题?BUG

发布于 2024-09-10 09:43:35 字数 3020 浏览 1 评论 0原文

解决了!

$('#bset1').click(function(event) {                                                                 
    event.stopPropagation();                                                                                    
    });        

我的元素中有几个单选按钮。一切正常,但是当我将 .accordion() 添加到父 div 时,单选按钮停止工作(在初始选择之后

以下是​​链接: http://jsfiddle.net/Lrnj8/5/

去掉手风琴创建看看差别

$('[id^=rad]').click (function () {return false;}) 

不帮助

我过去一周一直在努力解决这个问题!最后,我编写了自己的 .click() 处理程序,但一定有更简单的方法!

$(function() {                                                                                                      
$("body")                                                                                                       
    .append($('<div/>')                                                                                         
        .attr ('id','main'));                                                                                   
var str1='<input type=radio id=rad1 name=r1><label for=rad1>1</label>'                                          
    +'<input type=radio id=rad2 name=r1><label for=rad2>2</label>'                                              
    +'<input type=radio id=rad3 name=r1><label for=rad3>3</label>';                                             

$('#main')                                                                                                      
    .append($("<h3/>")                                                                                          
        .append ($('<a>')                                                                                       
        .attr ({                                                                                                
        'id':'header1'                                                                                          
        })                                                                                                      
        .html('HEADER'))                                                                                        
        .append($('<span\>')                                                                                    
            .attr ('id','bset1')                                                                                
            .html (str1)                                                                                        
            ))                                                                                                  
//php takes care of that                                                                                                               
if (1==$_GET['a'])  $('#main').accordion();                                                         

}) 

SOLVED!

$('#bset1').click(function(event) {                                                                 
    event.stopPropagation();                                                                                    
    });        

I have several radio buttons in the element. Everything works fine, but when I add .accordion() to the parent div, radio buttons stop working (after the initial selection)

Here is the link:
http://jsfiddle.net/Lrnj8/5/

remove accordion creation to see the difference

$('[id^=rad]').click (function () {return false;}) 

does not help

I've been struggling with this for the past week! In the end, I wrote my own .click() handler, but there must be an easier way!

$(function() {                                                                                                      
$("body")                                                                                                       
    .append($('<div/>')                                                                                         
        .attr ('id','main'));                                                                                   
var str1='<input type=radio id=rad1 name=r1><label for=rad1>1</label>'                                          
    +'<input type=radio id=rad2 name=r1><label for=rad2>2</label>'                                              
    +'<input type=radio id=rad3 name=r1><label for=rad3>3</label>';                                             

$('#main')                                                                                                      
    .append($("<h3/>")                                                                                          
        .append ($('<a>')                                                                                       
        .attr ({                                                                                                
        'id':'header1'                                                                                          
        })                                                                                                      
        .html('HEADER'))                                                                                        
        .append($('<span\>')                                                                                    
            .attr ('id','bset1')                                                                                
            .html (str1)                                                                                        
            ))                                                                                                  
//php takes care of that                                                                                                               
if (1==$_GET['a'])  $('#main').accordion();                                                         

}) 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

街角迷惘 2024-09-17 09:43:35

您必须在每个 H3(部分)之后的 div 中插入无线电

<div id="main">
    <h3><a>TEST</a></h3>
    <div>
        <input type="radio" id="rad1" name="r1" /><label for="rad1">1</label>
    </div>
    <h3><a>TEST</a></h3>
    <div>
        <input type="radio" id="rad2" name="r1" /><label for="rad2">2</label>
    </div>
    <h3><a>TEST</a></h3>
    <div>
        <input type="radio" id="rad3" name="r1" /><label for="rad3">3</label>
    </div>
</div>

您可以尝试这个实例

http://jsfiddle.net /Lrnj8/

You must insert your radios inside a div after each H3 (sections)

<div id="main">
    <h3><a>TEST</a></h3>
    <div>
        <input type="radio" id="rad1" name="r1" /><label for="rad1">1</label>
    </div>
    <h3><a>TEST</a></h3>
    <div>
        <input type="radio" id="rad2" name="r1" /><label for="rad2">2</label>
    </div>
    <h3><a>TEST</a></h3>
    <div>
        <input type="radio" id="rad3" name="r1" /><label for="rad3">3</label>
    </div>
</div>

You can try this live example

http://jsfiddle.net/Lrnj8/

可爱咩 2024-09-17 09:43:35
$('#bset1').click(function(event) {
    event.stopPropagation();
});        
$('#bset1').click(function(event) {
    event.stopPropagation();
});        
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文