Submit Selector Example
RUN
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Học lập trình miễn phí tại freetuts.net</title> <script src="https://freetuts.net/cnd/js/jquery/jquery-3.2.1.min.js"></script> </head> <body> <h1>Học lập trình miễn phí tại freetuts.net</h1> <form> <table id="exampleTable" border="1" cellpadding="10"> <tr> <th> Element Type </th> <th> Element </th> </tr> <tr> <td> <input type="button" value="Input Button"> </td> </tr> <tr> <td> <input type="checkbox"> </td> </tr> <tr> <td> <input type="password"> </td> </tr> <tr> <td> <input type="submit"> </td> </tr> <tr> <td> <input type="text"> </td> </tr> <tr> <td> <select><option>Option</option></select> </td> </tr> <tr> <td> <button>Button</button> </td> </tr> <tr> <td> <button type="submit">Button type="submit"</button> </td> </tr> </table> </form> <hr> <button onclick="myFunction()">Click vào đây để xem kết quả</button> <script> function myFunction(){ var submitEl = $( "td :submit" ) .parent( "td" ) .css({ background: "yellow", border: "3px red solid" }) .end(); $( "#exampleTable" ).find( "td" ).each(function( i, el ) { var inputEl = $( el ).children(), inputType = inputEl.attr( "type" ) ? " type='" + inputEl.attr( "type" ) + "'" : "" ; $( el ).before( "<td>" + inputEl[ 0 ].nodeName + inputType + "</td>" ); }) } </script> </body> </html>
PHÓNG TO