JQuery中两个对象之间的数据链接 [英] Data Link between two objects in JQuery

查看:117
本文介绍了JQuery中两个对象之间的数据链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想知道如何使用.link()在jquery中链接两个变量 http://api .jquery.com/link/.

I just want to know how can i link two variables in jquery using .link() http://api.jquery.com/link/.

我有两个变量var名称;和var firstname; ,我应该将名称"链接到名字".如果我对名称"进行了任何更改,则意味着它应反映在名字"中,反之亦然.

I have two variable var name; and var firstname; , i should link "name" to "firstname". If i made any changes to "name" means it should reflect in "firstname" and vise versa.

推荐答案

我对jQuery的link()插件没有太多经验,但似乎那个插件更多地用于将用户界面元素链接到Javascript中的变量,而不是将两个变量链接在一起,以便当一个变量值更改时,第二个变量也照搬.

I don't have much experience with the link() plugin for jQuery, but it seems that that plugin is designed more for linking user interface elements to variables in Javascript, not for linking two variables together so that when one changes value the second one will follow suit.

您到底想做什么?变量的重点是包含变量数据,如果您尝试访问一个名为firstname的变量,该变量将由其范围内的另一个变量name进行调整,那么您可以(并且应该)而是直接访问name变量,而不是尝试创建变量的副本.

What are you trying to do exactly? The point of variables would be to contain, well, variable data, and if you're trying to access a variable called firstname which would be adjusted by another variable in its scope called name, then you could (and should) rather just access the name variable directly, and not attempt to create copies of variables.

这篇关于JQuery中两个对象之间的数据链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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