如果需要通过js获取某个标签的属性,有以下方法。
通过id
1
2
3
4
5
6$(function(){
let row = $("#id");
let qrcode_img_base64 = row.getAttribute("content_qrcode_base64");
let qrcode_path = row.getAttribute("qrcode_path")
let amount = row.getAttribute("amount")
})通过标签
html文件中添加标签:aria-label=”qrcode”1
2
3
4
5
6
7
8
9
10
11
12
13
14
15<tbody>
{% for qrcode in qrcode_all %}
<tr>
<td width="20%">{{ qrcode.content_id }}</td>
<td width="20%">{{ qrcode.content_type }}</td>
<td width="20%">
<a href="#" aria-label="qrcode" id="showQRCode_{{ qrcode.content_id }}"
qrcode_path="{{ qrcode.qrcode_path }}" amount="{{ qrcode.amount }}"
content_qrcode_base64="{{ qrcode.content_qrcode_base64}}" rel="showQRCode">显示二维码</a>
</td>
<td width="20%">{{ qrcode.amount }}</td>
<td width="20%">{{ qrcode.create_time }}</td>
</tr>
{% endfor %}
</tbody>
1 | $(function(){ |
