我写了一个简单的代码来测试mailto属性
$("#proptype").change(function() {
switch(this.value) {
case 'Residential':
$("#testres").show('slow');
$("#testcom").hide('slow');
$("#propunit").prop( "disabled", false );
break;
case 'Commercial':
$("#testres").hide('slow');
$("#testcom").show('slow');
$("#propunit").prop( "disabled", true );
break;
default:
$("#testres").hide('slow');
$("#testcom").hide('slow');
$("#propunit").prop( "disabled", false );
}
});
此代码适用于 <button style="background-color: #0288D1" class="btn waves-effect waves-light">
<a href="mailto:xyz@abc.com?Subject=Getting%20source%20code" style="color: #ffffff;" target="_blank"> Contact us
</a>
</button>
。但在Chrome 62.0.3202.94
和Firefox 57 (Quantum)
中无效。如何使上述代码成为跨浏览器解决方案?
答案 0 :(得分:1)
按钮和锚点不能嵌套,它们都是尝试捕获click事件的动作元素。
您可以将外部<button>
设为<span>
,也可以将样式和类直接放在锚点上。