为什么我的整个代码不起作用?
请参阅我一直在创建一个国家/地区选择器。在我的上一个问题中 - dampe(已接受)、jammon、Jani Hartikainen,prodigitalson 对我帮助很大!他们为我提供了一个在我的 jsFiddle 中工作的代码,但是当将其传输到我的真实 html 页面时,我猜它不起作用,因为当我选择任何国家/地区(元素类型 a
/link< /code> 和 classed
country_link
)我的输入(classed country_input
)值不会更改为该国家/地区!我不知道我的代码出了什么问题,所以我想向你们寻求帮助。谁能帮我一下。 (下面是我的问题的 jsFiddle 页面!)
提前致谢
See I have been creating a Country selector. And in my previous question - dampe (accepted), jammon, Jani Hartikainen, prodigitalson helped me a lot! They provided me a code that was working in my jsFiddle but when transferred it to my real html page , I guess it is not working because when I select any Country (Element type a
/link
and classed country_link
) my input (classed country_input
) value does not changes to that country! I don't know what is getting wrong with my code, so I thought to you ask for help from you guys. Can anyone help me out. (Below is my problem's jsFiddle page!)
THANKS IN ADVANCE
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是你的国家/地区选择器在将值分配给元素之前被隐藏起来,在这种情况下,javascript 不会“看到”你试图从中获取值的对象。
换句话说:您必须在从链接中获取值后隐藏国家/地区列表:
编辑:我还更新了您的 小提琴代码
The problem is that you country-selectors gets hidden away BEFORE it assigns the value to the element and in such case javascript dosen't 'see' the object you are trying to get the value from.
In other words: you have to hide the country list AFTER you have taken the value from the link as such:
Edit: I also updated your fiddle code