Question

I am trying to remove an element from a volusion page where I don't have access to large parts of the code. I can remove some stuff using jquery, but there are elements outside of the span I can't get rid of.

<span class="PageText_L329n">Quantity in Stock</span>:6<meta itemprop='availability' content='InStock'>

I can use

$("span.PageText_L329n").remove();

to get rid of the "Quantity in Stock" section, but the :6 doesn't have its own container. The parent div that this is sitting in has a lot of other stuff in it I don't want to touch. Is there a way to remove this span and the following several characters? Or separately select the :6 and remove it without a container?

Was it helpful?

Solution

Working Demo http://jsfiddle.net/tUBxc/1

JS

  $(document).ready(function () {
    var text = $('.PageText_L329n')[0].nextSibling;
    $(text).remove();
});

New Js by user2592238

$(document).ready(function () {
    $("body:contains('Quantity in Stock')").each(function () {
        var text = $(this).text();
        text = text.replace("Quantity in Stock:", "");
        $(this).text(text);
    });
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top