jQuery - add text and var to value

前端 未结 4 1689
广开言路
广开言路 2021-01-28 09:39

I want to add normal text and a jQuery value to an input value.

var amount = $(\'option:selected\', this).val();
    $(\'.customfield\').val(\'clicks,

        
相关标签:
4条回答
  • 2021-01-28 09:57

    Try this

    var amount = $('option:selected').val();
    $('.customfield').val('clicks, <?php echo $userdata["id"] ?>,'+amount+');
    
    0 讨论(0)
  • 2021-01-28 09:58

    Try this:

        $('.customfield').val('clicks,<?php echo $userdata["id"] ?>,' + amount);
    
    //--------double quote to id as is open and   ---------^^^^
    //                   closed by single quote and remove last +
    
    0 讨论(0)
  • 2021-01-28 10:03
    var amount = $('option:selected').val();
        $('.customfield').val('clicks,<?php echo $userdata['id'] ?>,' + amount);
    
    0 讨论(0)
  • 2021-01-28 10:22
    var amount = $('option:selected').val(); // or var amount = $('#selectDropwdownId').val();
        $('.customfield').val("clicks,<?php echo $userdata['id'] ?>," + amount );
    
    0 讨论(0)
提交回复
热议问题