0

I am trying to remove the word "Quantity" from below and I think I am close but obviously something is off since it's not working.

<div class="DetailRow" style="display: ;">
    <div class="Label">
        <label>Quantity</label>

With:

<script type="text/javascript">
$(document).ready(function(){
    $('#text_qty_').parent().parent().remove();
    $('#qty_').parent().parent().remove();
    $('.QuantityInput').remove();
    $('label[for="Quantity"]').css('display', 'none').remove();
});
</script>

8 Answers 8

1

Try doing it with pure js after adding an id.

<div class="DetailRow" style="display: ;">
<div class="Label">
<label id ="text">Quantity</label>

<script type="text/javascript">
$(document).ready(function(){
    document.getElementById("text").innerHTML = "";
});
</script>
Sign up to request clarification or add additional context in comments.

3 Comments

"pure JS" with $(...)? ;-)
Unfortunately I am trying to do it without touching the css. It's a theme in BigCommerce and I am just adding a product template.
Okay yeah... well I am trying to do it without editing the original css. And I am not good at this stuff, great at css and front-end design, but limping along at js and php.
0

Your label needs an id. In this example, I'll use "quantity" as the id.

$('label[id="quantity"]').hide();

This will work but this will apply the style to all labels.

$('label')

Using Pure JavaScript is best though.

1 Comment

Thanks, that's what I was afraid of.
0

Try this $('label').html('');.

1 Comment

Please consider editing your post to add more explanation about what your code does and why it will solve the problem. An answer that mostly just contains code (even if it's working) usually wont help the OP to understand their problem. It's also recommended that you don't post an answer if it's just a guess. A good answer will have a plausible reason for why it could solve the OP's issue.
0

$('label[for="Quantity"]') will not retrieve <label>Quantity</label> since it doesn't have the attribute for. Just use $('label') or $('.Label label') and it will work.

5 Comments

There are other <label>this</label> tags that have to remain.
Then how about using $('.Label label:first').remove();?
I wish it was that easy! There are a bunch of these that are generated as they change options for each product, so if I can't identify the word "Quantity" and remove it, then everything else will get messed up. If it's not possible then I'll just have to rewrite several pages and they will have to pay close attention any time there's an update to the template.
The how about $('label').filter(function() { return $(this).text() === "Quantity"; }).remove();?
Or $("label:contains('Quantity')").remove();
0

Try this if you want to remove the label element itself:

 var labels = $('label');
 if( labels.text() == 'Quantity' ){
      labels.remove();
}

To just remove the word Quantity without removing the label element:

labels.text('');

If you want to remove its parent:

labels.parent().remove();

Also to remove the parent's parent, the <div class="DetailRow"> use this:

labels.parent().parent().remove();

JSFiddle

Comments

0

You can use plain javascript and existing markup with querySelector:

var el = document.querySelector('.DetailRow .Label label');
if (el) {
  // do stuff
}

If you want to remove the content, then:

el.textContent = '';

If you want to remove the element, then:

el.parentNode.removeChild(el);

and so on…

Comments

0

I think you can check the label value, and remove the label if the value equals to "Quantity"

Try this:

<div class="DetailRow">
    <div class="Label">
        <label>Quantity</label>
    </div>
</div>

And the script:

$(document).ready(function(){
    $(".DetailRow label:contains('Quantity')").hide();
});

http://codepen.io/Himechi90/pen/rOJYjX

Comments

0

Thank you Griffith! This worked perfectly. Full code for anyone trying to remove the quantity and quantity box from only some of your products on bigcommerce. Note that you need to create a separate product template and add this below %%Panel.Header%%

<script type="text/javascript">
$(document).ready(function(){
$('#text_qty_').parent().parent().remove();
$('#qty_').parent().parent().remove();
$('.QuantityInput').remove();
$('label').filter(function() { return $(this).text() === "Quantity"; }).remove();
});
</script>

Note also that your values for #text_qty_ etc may change depending on your template.

Thank you all for taking the time to help me!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.