adding classes (serially numbered) to each DIV on page automatically via javascript?

后端 未结 3 1788
庸人自扰
庸人自扰 2021-01-15 03:15

i\'m running a contact-form-plugin on my wordpress installation. everything works fine but i want to style my form a little bit more. to do it like this i have to style some

3条回答
  •  说谎
    说谎 (楼主)
    2021-01-15 03:48

    You need something like this,

    Live Demo

    $('div').each(function(i, item){
        $(this).attr('class', "YourClass" + i); //You can replace i with some other variable if required and increment it.
    });
    

提交回复
热议问题