drwjv28028 2013-09-30 08:00
浏览 42
已采纳

使用JQuery / Javascript将值放入隐藏字段

I'm trying to place a data to a hidden field using JQuery, I want to place a text to the field "fieldName" with custom values, but I don't know how to pass the text to the field using jQuery.

The code that I used is:

$('span.open-apply-modal').click(function(){
    $('#apply-modal, #modal-backdrop').fadeIn(150);

});

The field is inside the div apply-modal.

I want to place the value "Accountant" to the hidden field after the FadeIn(150) is called. How do I do that?

  • 写回答

6条回答 默认 最新

  • duanganleng0577 2013-09-30 08:04
    关注

    Try:

    $('span.open-apply-modal').click(function(){
        $('#apply-modal, #modal-backdrop').fadeIn(150);
        $("#hidden_field_id").val('Accountant');
    });
    

    To put the value after the fade is executed try this:

    $('#apply-modal, #modal-backdrop').fadeIn(150, function(){
        $("#hidden_field_id").val('Accountant');
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?