Replacing a div class in SharePoint with jQuery1.4min in a content editor

Very new information on how jQuery works and tries to replace the class name of the pivot link tag div.

<div class="slm-layout-main groupmarker">sometext</div>  

want to change it to

<div class="slm-layout-main groupmarker ms-rteFontSize-3">sometext</div>

and there are many places to replace this diz tag.

I tried in ContentEditor something like this:

<script src="/sites/lrp/Shared%20Documents/jquery-1.4.2.min.js" type="text/javascript"></script><script type="text/javascript">

$(".slm-layout-main groupmarker")
.removeClass("slm-layout-main groupmarker")
.addClass("slm-layout-main groupmarker ms-rteFontSize-3");
</script>

Any help is appreciated. Thank,

+3
source share
2 answers

This will get all the elements with .slm-layout-mainand for each one that also has it .groupmaker, it will add .ms-rteFontSize-3. This does not apply when other classes are present.

$(".slm-layout-main").each(function(){
  if($(this).hasClass(".groupmaker")){
    $(this).addClass"ms-rteFontSize-3");
  }
});
+1
source

, . , css, , .slm-layout-main, <groupmarker>

$(".slm-layout-main groupmarker")

-

$(".slm-layout-main.groupmarker")

Edit
:

$(".slm-layout-main.groupmarker").each(function(){
   $(this)
      .removeClass("slm-layout-main groupmarker")
      .addClass("slm-layout-main groupmarker ms-rteFontSize-3");
});
+1

All Articles