jquery - 旁边的可链接图标
问题描述
解决方案
这是使用单选按钮的粗略版本。按钮通过 css 隐藏,标签是用户的实际界面。
然后,您仍然可以通过单选按钮的名称获得表单元素。
//This is a better way to wire up your event handler
//instead of inline javascript
var radios = document.querySelectorAll(".selctRadio input[type=radio]");
for(i = 0; i < radios.length; i++)
{
radios[i].addEventListener("click", submitForm);
}
//Just to demo the handler, put/change your logic here
function submitForm(){
console.log(this.name + " : " + this.value);
}
/*Style the list*/
.selctRadio {
list-style: none;
padding-left: 0;
}
/*Hide the radio button*/
.selctRadio input[type=radio] {
display: none;
}
/*Style the select*/
.selctRadio label {
display: block;
}
/*Add some styling when checked*/
.selctRadio input[type=radio]:checked~label {
background-color: #CCC;
}
/*Set the list item to relative*/
.selctRadio {position:relative;}
/*So we can absolutely position the icon relative to it*/
.selctRadio .fa-film{
position:absolute;
right:0;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<p>Pay
<i class="fa fa-apple-pay"></i>
</p>
<div class="card">
<div class="card-header" id="heading67765">
<h2 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapse67765" aria-expanded="true" aria-controls="collapse67765">
a_format
<strong>210 x 75 mm</strong></button>
<span class="fa fa-code pull-right" data-container="body" data-toggle="popover" data-placement="left" data-html="true" data-content="" style="font-size: 16pt; margin-top: 10px;" data-original-title="" title=""></span>
</h2>
</div>
<div id="collapse67765" class="show*********** collapse show" aria-labelledby="heading67765" data-parent="#accordionExample" style="">
<div class="card-body">
<ul class="selctRadio">
<!-- Note the relationship between "id" on the input and "for" on the label -->
<li><input type="radio" name="a_format" value="A_52_x_74_mm_DIN-A-8" id="A_52_x_74_mm_DIN-A-8"><label for="A_52_x_74_mm_DIN-A-8">52 x 74 mm A8</label></li>
<li><input type="radio" name="a_format" value="A_74_x_105_mm_DIN-A-7" id="A_74_x_105_mm_DIN-A-7"><label for="A_74_x_105_mm_DIN-A-7">74 x 105 mm A7</label>
</li>
<li><input type="radio" name="a_format" value="A_210_x_75_mm" id="A_210_x_75_mm" checked><label for="A_210_x_75_mm">210 x 75 mm</label></li>
</ul>
</div>
</div>
</div>
<div class="card">
<div class="card-header" id="heading67765">
<h2 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapse67765" aria-expanded="true" aria-controls="collapse67765">
a_format
<strong>210 x 75 mm</strong></button>
<span class="fa fa-code pull-right" data-container="body" data-toggle="popover" data-placement="left" data-html="true" data-content="" style="font-size: 16pt; margin-top: 10px;" data-original-title="" title=""></span>
</h2>
</div>
<div id="collapse67765" class="show*********** collapse show" aria-labelledby="heading67765" data-parent="#accordionExample" style="">
<div class="card-body">
<ul class="selctRadio">
<li><input type="radio" name="a_paper" value="A_90gqm_Bilderdruck" id="A_90gqm_Bilderdruck"><label for="A_90gqm_Bilderdruck">90 gsm Coated art paper</label></li>
<li><input type="radio" name="a_paper" value="A_115gqm_Bilderdruck" id="A_115gqm_Bilderdruck"><label for="A_115gqm_Bilderdruck">115 gsm Coated art paper</label><a href="https://www.youtube.com" class="fa fa-film"></a></li>
<li><input type="radio" name="a_paper" value="A_130gqm_Bilderdruck" id="A_130gqm_Bilderdruck"><label for="A_130gqm_Bilderdruck">130 gsm Coated art paper</label></li>
</ul>
</div>
</div>
</div>
推荐阅读
- flutter - Flutter fromJson with integer / num 有问题
- sql - 列出出演喜剧多于戏剧和悲剧的演员,加起来
- android - Jetpack Compose:使用协程中的 lambda 调用函数时出现后端内部错误
- firebase - 如何使用本机反应绘制 Firebase 数据的实时图?
- locale - 伊莎贝尔解决解释
- java - MySQL JDBC 驱动程序无法将数据插入到只读副本上的临时表中
- c# - WPF 应用程序中配置 XML 的动态 MaterialDesign PackIconKind
- r - 如何设置 R Studio 以中断代码中的错误
- html - 当我将鼠标悬停在 ionic 提供的 github-logo 上时,如何覆盖标题“ionicons-v5_logos”
- audio - 选择要输出音频的扬声器