javascript - 加入2个输入Jquery?

标签 javascript jquery html

我有 HTML 基本代码

<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');

我会选择输入类型单选框,显示“我将提供 _ 页键入的内容”,其中 _ 是输入类型 number 的值。如何从点击输入单选时显示的输入数字中获取值?

最佳答案

从输入中删除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')
});

关于javascript - 加入2个输入Jquery?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31737800/

相关文章:

javascript - EmberJS 链接助手的问题

javascript - 数据表TableTools下载仅下载部分表

javascript - CORS 问题 - 从 Backbone JS 调用 Web 服务

javascript - 使用javascript在div内调整大小时更改字体大小

javascript - 将随机且不存在的项目从另一个数组添加到数组中

javascript - 如何在 Bootstrap 上触发下拉按钮模糊/关闭事件?

javascript - $(window).height() 提供的结果不一致;

html - 一起使用两个 css 类时更改样式

php - jQuery 模态确认

javascript - 学习 jQuery : if & else statements, 这有效吗?