Data Link between two objects in JQuery

风格不统一 提交于 2019-12-12 02:36:51

问题


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

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.


回答1:


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.

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.



来源:https://stackoverflow.com/questions/9066135/data-link-between-two-objects-in-jquery

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