简体   繁体   English

使用 jquery 将 class 添加到带有 class 的 div 内的字体

[英]add a class to font inside a div with a class using jquery

I have following html rendered in power portals and it is causing to break the formating of the input group.我在 power 门户中呈现了以下 html,它导致破坏了输入组的格式。

<div class="control">
    <div class="input-group" role="none">
       <font size="3" style="position: relative;">
          <input name="ctl00$ContentContainer$WebFormControl_3596f2cdce74ec11894300224812"....>
       </font>
    </div>
<div>

I have tried adjusting in dev tools and if I found that if apply a class of "input-group" to the font attribute everything formats nicely if it is like below.我已经尝试在开发工具中进行调整,如果我发现如果将“输入组”的 class 应用于字体属性,则所有格式都很好,如果它如下所示。

 <font size="3" class="input-group" style="position: relative;"></font>

I am not sure how to find the font attribute in dom using jQuery. I have tried this below but it seems to not do anything我不确定如何使用 jQuery 在 dom 中找到字体属性。我在下面尝试过,但它似乎什么也没做

$(document).ready(function () {
$('#WebFormPanel').each(function(e) {
    let divinputgroup = $(this).find("input-group");
         if(divinputgroup.length){
            $("font").addClass("input-group");
         }
    })
 });
   $(document).ready(function () {
$('#WebFormPanel').each(function(e) {
    let divinputgroup = $(this).find(".input-group");
         if(divinputgroup.length){
            $("font").addClass("input-group");
         }
      })
  });

You can use this and also you can give class to font, so that it can be use easily你可以使用这个,也可以给字体 class,这样就可以方便地使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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