1

I need to make a dynamic row counter for my table. I do this with a span but how do i run my javascript function on it so it prints the number out?

html;

<span id="Tellen"></span>

Javascript;

function tellen(){
    var rowCount = document.getElementById('tableID').rows.length;
}

Could someone help me into the right direction, much appreciated.

3

1 Answer 1

2

You didn't assign output to html span

Try this Tag :

<span id="Tellen"></span>

JS

function tellen(){
    var rowCount = document.getElementById('tableID').rows.length;
    document.getElementById('Tellen').innerText = rowCount
}

But you need some event to call tellen() .. It can be onClick of button or something like this

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.