user2850509
user2850509

Reputation:

Get information from object "this" javascript

I'm trying to retrieve the numbers that generates from this code:

$("#100wattaren")
    .countdown("2018/01/01", function(event) {
    $(this).text(
    event.strftime('%D dagar %H timmar %M minuter %S sekunder')
    );
});

If I console.log "this" it outputs the actual div with information, but I just wants whats inside the div so in this case 93 dagar 05 timmar....

<div id="100wattaren" class="award">93 dagar 05 timmar 12 minuter 02 sekunder</div>

I use the jQuery addon: http://hilios.github.io/jQuery.countdown/

Upvotes: 0

Views: 38

Answers (1)

tadman
tadman

Reputation: 211560

A lot of jQuery functions have dual use, mutator and accessor. If you call them with an argument they change values, with no argument simply returns what's there.

So to log the contents without altering it:

console.log($(this).text());

Upvotes: 2

Related Questions