MVC3 Razor: call javascript function from view

后端 未结 2 1499
忘掉有多难
忘掉有多难 2021-01-04 19:30

I am new in MVC3 Razor and want to show running time on a view (index.cshtml). I use a javascript function and put it in _Layout.cshtml so all other \"home\" views can use

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-04 20:12

    The last line of the datum function should return the time rather than setting the innerHTML:

    return 'Jetzt ist: ' + stunden + ':' + minuten + ':' + sekunden;
    

    and your HTML can then be something like this:

    The time is: 
    

提交回复
热议问题