-1
選択リストでオプションを無効/非表示にする必要があります。 しかし、この選択リストは私のコードにはなく、電子商取引のパターンです。JSまたはCSSでオプションを無効/非表示にする
そして、私たちは、次のJSを使用してコードを変更:
/*var buttons = "";
$("select option").each(function() {
buttons += "<input type='button' value='" + this.value + "'/>";
});
$("select").replaceWith(buttons);
*/
var selectName = $('select').attr('name');
// add a hidden element with the same name as the select
var hidden = $('<input type="hidden" name="'+selectName+'">');
hidden.val($('select').val());
hidden.insertAfter($('select'));
$("select option").unwrap().each(function() {
var btn = $('<div class="btn">'+$(this).text()+'</div>');
if($(this).is(':checked')) btn.addClass('on');
$(this).replaceWith(btn);
});
HTML + CSS EMBED:
<!-- Variações -->
<iluria.if.product.has.variations>
<div class="product-variations-container">
$iluria.product.variations
</div>
<script src="variations.js"></script>
<style>
div.btn {display: inline-block;border: 2px solid #ccc;margin-right: 5px;padding: 2px 5px;cursor: pointer;}
div.btn.on {background-color: #777;color: white;}
</style>
</iluria.if.product.has.variations>
$(document).on('click', '.btn', function() {
$('.btn').removeClass('on');
$(this).addClass('on');
$('input[name="'+selectName+'"]').val($(this).text());
});
画面:
https://i.stack.imgur.com/gz8NU.jpg
私は/非表示にする必要がありますオプションを無効にするTAMANHO
ありがとう!
サイトは有効ですか?その場合は、ページへのリンクを提供してください。あなたが提供したそのコードに基づいて複製することはできません。 –
はい、申し訳ありません。リンク:www.hdmclothing.com.br –
これがあなたのために働くか試してみてください。 '.product-variations-container> div:nth-child(4){ ディスプレイ:なし; } ' –