jQuery 1.7.1 - Text input's 'value' not updating in Firebug Inspect element but is on screen

限于喜欢 提交于 2019-12-04 11:45:11

The value attribute always shows the defaultValue. Firebug never displayed the current value in the attribute. The current value is always visible on the screen.

This has nothing to do with Firebug or jQuery, it is the HTML standard.

The attribute value never changes, only the property.

http://jsfiddle.net/cc5Pm/1/

var input = document.getElementsByTagName("input")[0];
setInterval(function(){
    input.value = parseInt(input.value) + 1;
    console.log(input.value, input.getAttribute("value"));
},1000);

Sometimes Firebug doesn't always reflect some changes, I have noticed this before.

If there is a refresh I haven't found it. You can either turn Firebug off and on again or just use the console to check the value has changed

console.log($("#event").val());

I've seen this too: i.e the value attribute of an input does NOT change in Firebug. Last time I paid attention to this was a while ago (like 2 years). Incidentally, I was using jQuery too, but I really doubt jQuery has anything to do with this. It's just how Firebug works (or at least worked).

Of course, you could still use the Firebug console to definitively get the value:

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