Get input control type : attr « jQuery « JavaScript Tutorial






<html>
  <head>
    <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
        $('#exampleTable').find('td').each(function(i, el) {
        var inputEl = $(el).children().get(0);
        $(el).before('<td>Added ' + $(inputEl).attr('type') + '</td>');
    })

        
    });
    </script>
  </head>
  <body>
     <form>
     <table id="exampleTable">
     <tr>
        <th>
            Type
        </th>
        <th>
            Element
        </th>
     </tr>
     <tr>
        <td>
            <input type="button" value="Input Button"/>
        </td>
     </tr>
     <tr>
        <td>
            <input type="checkbox" />
        </td>
    </tr>
    </table>
    </form>



  </body>
</html>








30.18.attr
30.18.1.Disable input control
30.18.2.Get attribute from tag
30.18.3.Get input control type
30.18.4.Set Image URL title alt
30.18.5.attr(key, fn)
30.18.6.Sets src attribute from title attribute on the image.
30.18.7.attr(key, value) set a single property to a value, on all matched elements.
30.18.8.Finds the title attribute of the first in the page.
30.18.9.attr(name): access a property on the first matched element.
30.18.10.Disable all form input controls
30.18.11.Add attribute and clear attribute
30.18.12.Set attribute with the returned function value