簡體   English   中英

獲取JS中隱藏輸入字段的值

[英]Get value of hidden input field in JS

我需要使用 JS 獲取隱藏輸入字段的值,

   var credoff = parseInt($(this).children('input.credoff:hidden').val());

在 FF 中工作正常但在 IE 中不起作用,我所說的輸入如下......

<input type='hidden' value='$row->coff' class='credoff' name='credoff'/> 

你可以試試input[type='hidden']嗎?

'credoff' class 還有很多其他元素嗎?

jQuery 文檔中有與此相關的:hidden 選擇器的注釋。

http://api.jquery.com/hidden-selector/

顯然在 IE 中,:hidden 選擇器也會選擇元素,因此您可能無法取回正確的元素。 你可以試試

var credoff = parseInt($(this).children('input.credoff:hidden').not('option').val());

這可能有效:

var credoff = parseInt($(this).children('input[name="credoff"]').val());

雖然我不知道“這個”是什么。 更多代碼會有所幫助。

或這個:

var credoff = parseInt($(':input[type:"hidden"][name:"credoff"]').val());

這必須有效:

var credoff = parseInt($(this).children('input[name="credoff"][type="hidden"]').val());

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM