传递一个variabe jQuery的使用里程表 [英] Passing a variabe to jquery using Odometer

查看:114
本文介绍了传递一个variabe jQuery的使用里程表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用一个jQuery里程表显示在主页上的信息。 <一href=\"http://www.jqueryscript.net/animation/Smooth-Animated-Numbers-with-Javascript-CSS3-odometer.html\" rel=\"nofollow\">http://www.jqueryscript.net/animation/Smooth-Animated-Numbers-with-Javascript-CSS3-odometer.html

在为了做到这一点我必须检索使用C#的SQL Server的价值。然后,我必须把它传递给JScript的里程表在html(),如下图所示。如果我得到valuje - 怎么做Isend它的JavaScript

 &LT;脚本&GT;
      的setTimeout(函数(){
        $('。里程表)HTML('123222')。
      },1000);
    &LT; / SCRIPT&GT;


解决方案

您可以使用下面的实现来通过从code背后的价值将jQuery

这是一个例子如何做到这一点。

首先声明在code公共变量背后

//声明在code公共变量背后

 公共字符串odometervalue =667;

阅读以下

给出jQuery中像值

 &LT;脚本&GT;
        $(函数(){
            的setTimeout(函数(){
                //从服务器端的价值
                VAR的uid ='&LT;%= odometervalue%GT;';
                odometer.innerHTML = UID;
            },1000);
        });    &LT; / SCRIPT&GT;

I would like to use a jquery odometer to display information on a master page. http://www.jqueryscript.net/animation/Smooth-Animated-Numbers-with-Javascript-CSS3-odometer.html

In order to do that I have to retrieve that value from SQL Server using C#. Then I have to pass it to the jscript odometer in the html() as shown below. If I get the valuje - how do Isend it to the javascript?

<script>
      setTimeout(function(){
        $('.odometer').html('123222');
      }, 1000);
    </script>

解决方案

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>

这篇关于传递一个variabe jQuery的使用里程表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆