Sify Juhy
Sify Juhy

Reputation: 177

how to use a javascript many time on a page?

<script type="text/javascript">
        $(function() {
            var newYear = document.getElementById('HF');
            alert('hehe' + newYear);
            $('#countdown').countdown({ until: newYear, format: 'DHMS', layout:
'<div id="timer">' + '<hr />' +
    '<div id="timer_days" class="timer_numbers">{dnn}</div>' +
    '<div id="timer_hours" class="timer_numbers">{hnn}</div>' +
    '<div id="timer_mins" class="timer_numbers">{mnn}</div>' +
    '<div id="timer_seconds" class="timer_numbers">{snn}</div>' +
'<div id="timer_labels">' +
    '<div id="timer_days_label" class="timer_labels">days</div>' +
    '<div id="timer_hours_label" class="timer_labels">hours</div>' +
    '<div id="timer_mins_label" class="timer_labels">mins</div>' +
    '<div id="timer_seconds_label" class="timer_labels">secs</div>' +
'</div>' +
'</div>'
            });
        });
</script>

How can i use this script many times on the page???I have three listViews ont the page so i want to use it 3 times??how can i do that??

Upvotes: 0

Views: 94

Answers (3)

Moin Zaman
Moin Zaman

Reputation: 25445

Give the listviews the same class, eg. .countdown and then change your JavaScript to $('.countdown').countdown(...

Upvotes: 0

Royi Namir
Royi Namir

Reputation: 148524

change from using $('#countdown'). to using by class $('.countdown').

Upvotes: 0

Uku Loskit
Uku Loskit

Reputation: 42040

You could have a countdown class instead of an id, so you could use the $(".countdown") selector instead.

Upvotes: 1

Related Questions