将选择输入中的数据从模态显示到范围

时间:2018-05-08 03:36:26

标签: jquery html

如何在模态外显示从模态到跨度的选择输入的值?这是我到目前为止所得到的:这是我的模态:



#date.modal.inmodal.fade(tabindex='-1' role='dialog' aria-hidden='true')
  .modal-dialog.modal-m
    .modal-content
      .modal-header
        button.close(type='button' data-dismiss='modal')
          span(aria-hidden='true') ×
          span.sr-only Close
        h4.modal-title Select reporting month
      .modal-body
        .form-group
          h4
            i.fa.fa-calendar
            |  Month
          .selectContainer
            select.form-control(name='month')
              option(value='') Choose a month
              option(value='') January
              option(value='') February
              option(value='') March
              option(value='') April
              option(value='') May
              option(value='') June
              option(value='') July
              option(value='') August
              option(value='') September
              option(value='') October
              option(value='') November
              option(value='') December
        .form-group
          h4
            i.fa.fa-calendar
            |  Year
          .selectContainer
            select.form-control(name='year')
              option(value='') Choose a year
              option(value='') 2017
              option(value='') 2018
      .modal-footer
        button.btn.btn-white(type='button' data-dismiss='modal') Close
        button.btn.btn-primary(type='button') Save




这是我需要显示它们的值的范围



h3
  strong
    em CCP Manual testing metrics report 
  br
  span <--- THE SPAN WHERE I NEED THE VALUE OF THE MONTH -->
    em 
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

将班级分配给span,例如display。这使得在文档中更容易找到它。以下是从下拉列表中读取内容并在跨度中显示内容的方法:

const month = $("select.form-control[name='month']").val();
const year = $("select.form-control[name='year']").val();

$('span.display').text(`Month: ${month}, Year: ${year}`);