【发布时间】:2017-07-20 09:01:22
【问题描述】:
我的问题:由 id 传递的值显示在输入框中。但我在 html 源代码部分中看不到该值。
这是我通过 cookie 传递值的输入字段。
<input type="text" id="city" class="i-p-c" value="" autocomplete="off" placeholder="Select City">
我正在做的是:我有一个城市的下拉列表。当我点击城市时。我正在设置一个名为 scity 的 cookie。
$("#cuto li").click(function () {
autoValuenew = this.id; // console.log(autoValuenew);
document.cookie = "scity=" + this.id + ";path=/;domain=" + cookieondomain;
document.getElementById('city').value = this.id;
//Here is am pass a value to city
return false;
});
在那之后.. 我可以访问 city 的值,但在 html 源代码中看不到该值。
当我将字段类型文本更改为隐藏类型时,我可以在 html 源代码中看到值。
我不明白这两种类型的情况。或者如果我在做某事,请告诉我哪里做错了。或者如果有其他方法可以做到这一点。
【问题讨论】:
-
你说的在html元素部分看不到那个值是什么意思?
-
在我的源代码@H77
-
控制台窗口中是否出现任何错误?
-
不.. 我没有得到@M.Nabeel
标签: javascript jquery html cookies