2011-12-02 64 views

回答

0
summary::-webkit-details-marker { 
    display: none; 
} 

http://jsfiddle.net/x8csg/1/

+0

非常感谢您的回复!但是,当你点击时间仍然会触发行为。 –

0

取决于你想做的事,我可以建议以下内容:

$('details').click(function(e){ e.preventDefault(); }); 

你必须阻止默认行为。就像你想阻止按钮提交表单...

请记住,在这种情况下,细节会被隐藏,所以你必须更改为:

0

仅供参考,更完整的答案 - 这必须在两个CSS和Javascript进行调整:

的Javascript:

var d=document.querySelectorAll('details:not(open)'), 
    i=d.length, 
    f=function(e){e.preventDefault();}; 

while(i-- > 0) { 

    // set the open attribute to the elements that doesn't have one 
    d[i].setAttribute('open',''); 

    // disable open/close behavior 
    d[i].onclick = f; 
} 
// cleanup 
delete(d); 
delete(i); 
delete(f); 

或者jQuery的风格:

$('details:not(open)').attr('open',true).click(function(e){ e.preventDefault(); }); 

CSS:

/* disable <summary> marker/arrow on webkit */ 
summary::-webkit-details-marker { display: none;} 

/* disable outline when clicked */ 
summary:focus{outline:none;} 
+0

把你的代码放在一个闭包中会比试图删除全局变得更清洁。 –

相关问题