jQuery access input hidden value

前端 未结 9 1861
执念已碎
执念已碎 2020-11-28 01:50

How can I access tag\'s value attribute using jQuery?

9条回答
  •  一整个雨季
    2020-11-28 02:53

    To get value, use:

    $.each($('input'),function(i,val){
        if($(this).attr("type")=="hidden"){
            var valueOfHidFiled=$(this).val();
            alert(valueOfHidFiled);
        }
    });
    

    or:

    var valueOfHidFiled=$('input[type=hidden]').val();
    alert(valueOfHidFiled);
    

    To set value, use:

    $('input[type=hidden]').attr('value',newValue);
    

提交回复
热议问题