locked
what is type of select RRS feed

  • Question

  • User-1634604574 posted

    i wrote this code if i clicked on td if it has input but if it has select how can i write this

    $("#table_sales_person_schedule").off("focus", "tr").on("focus", "tbody tr", function () {

    var series = $(this).find("td:eq(1) select").val();

    })

    $(this).find("td:eq(1) select").val(); this code is finding select 

    Sunday, March 17, 2019 11:23 AM

All replies

  • User475983607 posted

    zhyanadil.it@gmail.com

    i wrote this code if i clicked on td if it has input but if it has select how can i write this

    $("#table_sales_person_schedule").off("focus", "tr").on("focus", "tbody tr", function () {

    var series = $(this).find("td:eq(1) select").val();

    })

    $(this).find("td:eq(1) select").val(); this code is finding select 

    It is not possible to accurately answer this question without the HTML markup.  Have you tried doing basic troubleshooting with the Browser's dev tools?  Or perhaps reading the jQuery documentation?

    Sunday, March 17, 2019 1:45 PM
  • User839733648 posted

    Hi zhyanadil.it@gmail.com,

    According to your description and code, I suggest that you could use .each function to traverse the select value in your table.

    I've made a sample and maybe you could refer to.

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <title></title>
        <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
        <script>
            $(function () {
                $('#table1 tbody tr').each(function () {
                    var selVal = $(this).find('td:eq(1) select').val();
                    console.log(selVal);
                });
    
            })
        </script>
    </head>
    <body>
        <table id="table1">
            <tbody>
                <tr>
                    <td>111</td>
                    <td>
                        <select>
                            <option>aaa</option>
                            <option>bbb</option>
                        </select>
                    </td>
                    <td>222</td>
                </tr>
            </tbody>
        </table>
    </body>
    </html>

    result:

    Best Regards,

    Jenifer

    Monday, March 18, 2019 5:47 AM