加入2输入Jquery?

时间:2015-07-31 03:54:16

标签: javascript jquery html

我有代码HTML basic

<div class="w-input-number-change">
    <input class="other-select input-number-change" type="radio" data-price="110" data-value="I will supply ___ pages of typed content" name="copy">
    I will supply 
    <input class="other-select input-number-change-value" type="number" data-price="110" data-value="pages of typed content" name="copy" value="1"> 
    pages of typed content. 
</div>  

我得到价值输入型电台

$content_radio =  $('.input-number-change').data('value');

我会选择输入型收音机,显示&#34;我将提供 _页面的打字内容&#34; with _ 是输入类型编号的值。点击输入电台时如何从输入数字中获取值?

1 个答案:

答案 0 :(得分:1)

从输入中删除data-value,您可以轻松地按以下方式获取:

<强> DEMO

<强> HTML

<div class="w-input-number-change">
        <input class="other-select input-number-change" type="radio" data-price="110" name="copy"/>
         I will supply
        <input class="other-select input-number-change-value" type="number" data-price="110" data-value="pages of typed content" name="copy" value="1"/> 
        pages of typed content. 
</div>  

<强> JS

$('.input-number-change').on('click',function(){
    var value=$(this).siblings('.input-number-change-value').val();
    alert('I will supply '+value +' pages of typed content')
});