我如何在一个ID下的所有文本输入中添加一类



使用jquery

给出所有文本输入class" form-control"表格。
<table class="table table-bordered table-hover table-striped" id="table-form">
  <tr valign="baseline">
    <td nowrap align="right">ID:</td>
    <td><?php echo $row_Recordset1['ID']; ?></td>
  </tr>
  <tr valign="baseline">
    <td nowrap align="right">Cid:</td>
    <td><input type="text" name="cid" value="<?php echo htmlentities($row_Recordset1['cid'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
  </tr>
  <tr valign="baseline">
    <td nowrap align="right">Text:</td>
    <td><input type="text" name="text" value="<?php echo htmlentities($row_Recordset1['text'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
  </tr>
  <tr valign="baseline">
    <td nowrap align="right">Star:</td>
    <td><input type="text" name="star" value="<?php echo htmlentities($row_Recordset1['star'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
  </tr>
  <tr valign="baseline">
    <td nowrap align="right">&nbsp;</td>
    <td><input type="submit" value="Update record"></td>
  </tr>
</table>

使用jQuery

给出所有文本输入,带有id"表格"的"形式控制"类

您可以这样做。

$('#table-form input[type=text]').addClass('form-control');

最新更新