V
V
valitskiydmitriy2015-10-27 21:46:30
JavaScript
valitskiydmitriy, 2015-10-27 21:46:30

Changing content in only one div block, in js?

There is such a JS code that changes the price when you select the desired select.

$('.options select').change(function() {
        var option = $(this).children('option:selected');
        $('.price .price-new').html(option.data('new_price'));
        $('.price .price-old').html(option.data('old_price'));

        if (option.data('new_price') == option.data('old_price')) {
            $('.price .price-old').html('');
        };
    });

Here is the html
<span class="price-new"><?php echo $product['special']; ?></span>

There are two spans on the page, one for stocks and one for products. When changing the product option, the price changes both there and there, how can I make sure that only the first field changes?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Valery, 2015-10-27
@supervaleha

Select the first one found: jquery.page2page.ru/index.php5/%D0%9F%D0%B5%D1%80%...
well, or give an additional class to the desired span and knock specifically to it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question