I need to get the value of a hidden input field using JS,
var credoff = parseInt($(this).children('input.credoff:hidden').val());
which works fine in FF but does not work in IE, the input im talking of is the following...
<input type='hidden' value='$row->coff' class='credoff' name='cre开发者_StackOverflow中文版doff'/>
Could you try input[type='hidden']
?
Are there many other elements with the 'credoff' class?
There are comments in the jQuery documentation for the :hidden selector related to this.
http://api.jquery.com/hidden-selector/
Apparently in IE, the :hidden selector also selects elements, so it's possible that you're not getting back the right element. You could try
var credoff = parseInt($(this).children('input.credoff:hidden').not('option').val());
This might work:
var credoff = parseInt($(this).children('input[name="credoff"]').val());
Although I don't know what 'this' is. More code would be helpful.
Or this:
var credoff = parseInt($(':input[type:"hidden"][name:"credoff"]').val());
This must work:
var credoff = parseInt($(this).children('input[name="credoff"][type="hidden"]').val());
精彩评论