Passing a variabe to jquery using Odometer

大憨熊 提交于 2019-12-04 20:40:36

You can use the below implementation to pass the value from code behind to Jquery

This is one example how to do it.

First Declare a Public Variable in code behind

//Declare a Public Variable in code behind

 public string odometervalue = "667";

Read the value in Jquery Like given below

<script>
        $(function () {
            setTimeout(function () {
                //Get the value from serverside
                var uid = '<%=odometervalue  %>';
                odometer.innerHTML = uid;
            }, 1000);
        });

    </script>

Try this html

</head>
<body>

<script src="https://rawgit.com/HubSpot/odometer/v0.4.6/odometer.min.js"></script>
<style src="https://rawgit.com/HubSpot/odometer/master/themes/odometer-theme-default.css"></style>

<script>
  odometerOptions = { 
    auto: false 
};
</script>

<script type = "text/javascript">
  $(function(){
    var exampleOdometerValue = 123456;
    var exampleOdometer = new Odometer({ el: $('.odometer-example')[0], theme: 'digital', value: exampleOdometerValue });
    exampleOdometer.render()

    setTimeout(function(){
      exampleOdometerValue = exampleOdometerValue+100.07;
      exampleOdometer.update(exampleOdometerValue);
    }, 2000);

  });
</script>
<div class="odometer odometer-example">123</div>

</body></html>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!