Skip to content
Advertisement

Perform Function After Element Is Revealed

I’m working on a website where a div tag reveals itself after enough products are selected. What I’m trying to do is add an ID to this div tag after it’s revealed using javascript.

This is the tag that’s revealed:

<div class="discount-summary"></div>

This is the javascript I’ve created:

$(".discount-summary").load($(this),function(){
   addDiscount();
});

function addDiscount() {
            $('.discount-summary').attr('id','discountbox');
}

Unfortunately, this does not appear to be working.

Advertisement

Answer

Updated

Try:

<div class="discount-summary">Just a test</div>
$( document ).ready(function() {
    setInterval(addDiscount, 1000)
});

function addDiscount() {
    $('.discount-summary').attr('id','discountbox');
}

CodePen

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement