Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 从表中读取值,并单击按钮上的下拉列表_Jquery_Html - Fatal编程技术网

Jquery 从表中读取值,并单击按钮上的下拉列表

Jquery 从表中读取值,并单击按钮上的下拉列表,jquery,html,Jquery,Html,我有一个代码,可以在单击按钮时动态读取表中两列(成员、描述)的值 从表中读取值的JQuery: $(function() { $('#myButton').on('click', function() { var myCollection = []; $('div#body').find('tr:gt(0)').each(function() { var row = this; var myObj = { label: val

我有一个代码,可以在单击按钮时动态读取表中两列(成员、描述)的值

从表中读取值的JQuery:

$(function() {
  $('#myButton').on('click', function() {

    var myCollection = [];

    $('div#body').find('tr:gt(0)').each(function() {
      var row = this;
      var myObj = {


        label: valuefromType($(row).find($(row).find('td:eq(1)').children())),
        opis: valuefromType($(row).find($(row).find('td:eq(2)').children()))


      };
      myCollection[myCollection.length] = myObj;

    });

    console.log(myCollection)

    function valuefromType(control) {
      var type = $(control).prop('nodeName').toLowerCase();
      switch (type) {
        case "input":
          return $(control).val();
          break;
        case "span":
          return $(control).text();
          break;
        case "select":
          return $(control).val();
          break;
      }
    }

  });

});
在单击按钮时,存储在数组中的结果为:

0: Object { label: "1", opis: null }
1: Object { label: "2", opis: "test2" }
​2: Object { label: "3", opis: "test3" }
3: Object { label: "5", opis: "3" }
4: Object { label: "9", opis: "test5" }
5: Object { label: "15", opis: "test88" }
现在我需要jquery从位于上方的下拉列表(House Center)中获取所选值(1,2,3,4,5…),并在单击按钮时将其存储在第三列的数组中

在我的代码中,当我单击“来自”下拉列表中的值时,页面将刷新并生成一个新表,以便它可以是.on('change',function()


有人能帮我吗?

可能重复您上一个问题中我编辑的答案。好的,谢谢您的回答!我现在正在测试:)我以前回答过这个问题!