我想為內部 svg設定y值。tspan
svg 是這樣的(為簡單起見,我洗掉了一些部分,完整的代碼在這里:https ://0bin.net/paste/VKLkhpMK#HkAkhB0vVSN-ZVE9yUnWRkbgfzuN S bWt U15wMJxe ):
<div class="chart" style="margin-top: -50px">
<div id="jvwbtduzlfxnprgyeskhiqaoc" style="min-height: 288.7px;">
<div id="apexchartsq5s3epfr" class="apexcharts-canvas apexchartsq5s3epfr apexcharts-theme-light" style="width: 270px; height: 288.7px;">
<svg id="SvgjsSvg1001" width="270" height="288.70000000000005" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.dev" class="apexcharts-svg" xmlns:data="ApexChartsNS" transform="translate(0, 0)" style="background: transparent;">
<g id="SvgjsG1016" class="apexcharts-datalabels-group" transform="translate(0, 0) scale(1)" style="opacity: 1;">
<text id="SvgjsText1017" font-family=""Nunito"" x="138" y="138" text-anchor="middle" dominant-baseline="auto" font-size="16px" font-weight="600" fill="#008744" class="apexcharts-text apexcharts-datalabel-label" style="font-family: Nunito;">
<tspan id="SvgjsTspan1018">8 / 8 1</tspan> // set y="150" (the value for id is unique, so I can't using it)
</text>
<text id="SvgjsText1019" font-family=""Nunito"" x="138" y="170" text-anchor="middle" dominant-baseline="auto" font-size="14px" font-weight="400" fill="#373d3f" class="apexcharts-text apexcharts-datalabel-value" style="font-family: Nunito;">100%</text>
</g>
</svg>
</div>
</div>
</div>
我試過這樣:
<script>
$('.apexcharts-datalabel-label tspan').attr('y', 150);
</script>
但是什么都沒有改變,我不知道為什么。我上面的代碼在其他頁面上作業,但不適用于這個頁面。
uj5u.com熱心網友回復:
以下選擇器應該可以作業:
.apexcharts-text.apexcharts-datalabel-label tspan
因此查詢將更改為:
$('.apexcharts-text.apexcharts-datalabel-label tspan').attr('y', 150);
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/471088.html
標籤:javascript jQuery
