简体   繁体   中英

How to add a class for this section

Hi I have working on wordpress site, but I need to add a class to a DIV section. But directly I could not access that DIV section. So I need to add a class using jquery. Below is my code

<div class="et_pb_code et_pb_module  et_pb_code_0">
 <div class="form-container"> 
  <form>
   Below come form code..........
  </form> 
 </div>
</div>

This is the design of form picture so I need to add a class next to form-container

Use addClass method:

$('.et_pb_code .form-container').addClass('your-desired-class');

.addClass( className )
Adds the specified class(es) to each element in the set of matched elements.

You can select an element by class. So if you want to add a class to the external div you could use

$('div.et_pb_code.et_pb_module.et_pb_code_0')

Then just use addClass as normal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM