當按鈕按下去後放入icon,但本身按鈕會變形

<button class="add_tab_v2" onclick="location.href='xxx.php';">←</button>

$(".add_tab_v2").click(function(e) {

    $(".add_tab_v2").html("<img class='iconBack' src='images/loading_v2.svg'>");

    document.getElementById(".add_tab_v2").disabled=true;

});

當按下去後,丟了一張圖片給button

但這樣大小會變

https://img.mukewang.com/5c9c381200014f5e00970050.jpg


PS: 圖片越大,越變型

跟其他按鈕會不一樣

但我又不想限制按鈕本身的padding或寬度

因為這會因為字的多寡而也所限制....


MMMHUHU
浏览 443回答 2
2回答

明月笑刀无情

试试:<button class="add_tab_v2">←</button>$(".add_tab_v2").on(function(e) {&nbsp; &nbsp; setTimeout(function(){&nbsp; &nbsp; &nbsp; &nbsp; location.href='xxx.php';&nbsp; &nbsp; }, 3000);&nbsp; &nbsp; $(this)&nbsp; &nbsp; &nbsp; &nbsp; .text('')&nbsp; &nbsp; &nbsp; &nbsp; .css('background-image', 'url(images/loading_v2.svg)')&nbsp; &nbsp; &nbsp; &nbsp; .prop('disabled', true);});
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript