0

I want to put the value of javascript variable inside a class of </a>.

<script type="text/javascript">
    $('#sp-pt-151').countdown('2016/09/02', function(event) {
        $(this).html(event.strftime('%n'));
        var dd = event.strftime('%n');
    });
</script>

HTML

<a href="#"class="avatar-container p-dd personal">
     <img src="images/train.png" alt="" width:"100px" hieght:"100px" class="avatar"/>
</a>

As you can see in the "a" element class p-dd. I want the value of dd in it.

1 Answer 1

1

You can do it with:

$('#sp-pt-151').countdown('2016/09/02', function(event) {
    $(this).html(event.strftime('%n'));
    var dd = event.strftime('%n');

    $('a.p-dd').removeClass('p-dd').addClass('p-'+dd);

});

I suppose you have either single a element with that class, or you want to update class of all as with p-dd class.

Sign up to request clarification or add additional context in comments.

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.