使用jquery添加类属性

时间:2017-05-16 08:04:32

标签: jquery html

如何使用jquery在每个发送段落中添加类。请看下面的图片。 enter image description here

3 个答案:

答案 0 :(得分:3)

您可以使用CREATE OR REPLACE TRIGGER AFTERIUDLIQUIDATIONSDETAILS BEFORE INSERT OR DELETE ON LIQUIDATIONSDETAILS FOR EACH ROW --WHEN (NEW.PERIODID <> FN_PERIODNEXT) BEGIN If FN_PERIODNEXT <> :NEW.PERIOD then IF INSERTING THEN UPDATE APPOINTSOFCAS SET INLD = INLD + 1 WHERE CUSTOMERID = :NEW.CUSTOMERID AND ID = :NEW.APPOINTOFCAID AND KINDCONTROLID = :NEW.KINDCONTROLID; END IF; IF DELETING THEN UPDATE APPOINTSOFCAS SET INLD = INLD - 1 WHERE CUSTOMERID = :OLD.CUSTOMERID AND ID = :OLD.APPOINTOFCAID AND KINDCONTROLID = :OLD.KINDCONTROLID; END IF; END IF; END; / 以及.newsPostContainer p排除:not()元素:

.postDate

或者,如果您可以保证目标$('.newsPostContainer p:not(.postDate)').addClass('posteExcerpt'); 始终以p开头,那么您可以选择兄弟姐妹:

p.postDate

答案 1 :(得分:1)

检查遍历的'P'标签是否具有'postDate'类,如果没有,这是第二个'P'标签和addClass。

:not

已实现,您也可以使用df = df.reindex(columns = header_list)

答案 2 :(得分:0)

p.postDate + p会选择p后面的所有p.postDate

&#13;
&#13;
$(".newsPostContainer  p.postDate + p").addClass('posteExcerpt')
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="newsPostContainer ">
  <p class="postDate">postDate</p>
  <p>posteExcerpt</p>
  <p class="postDate">postDate</p>
  <p>posteExcerpt</p>
  <p class="postDate">postDate</p>
  <p>posteExcerpt</p>
  <p class="postDate">postDate</p>
  <p>posteExcerpt</p>
  <p class="postDate">postDate</p>
  <p>posteExcerpt</p>
</div>
&#13;
&#13;
&#13;