简体   繁体   English

jquery删除BR标签

[英]jquery removing BR tag

I am adding two tags dynamically when i click on remove button(just to make UI look better), I am not able to remove the space that those two BR's added. 我点击删除按钮时动态添加两个标签(只是为了让UI看起来更好),我无法删除这两个BR添加的空间。 If i see in console, it is showing me as 如果我在控制台中看到,它显示我
(lower case), I have tried uppercase,lowercase . (小写),我试过大写,小写。 remove(). 去掉()。

var container = $("#CCcontainer")
container.append("<div id =" + removeID + " ><div class =\"form-group col-sm-10\"></div><div class =\"form-group col-sm-2\"><button id=\"btn" + removeID + "\" type=\"button\" class=\"btn btn-warning form-control\">Remove Card</button></div></div></BR></BR>");

//Below line is in a remove Card click action.

 $( "<br/>" ).remove();

Could someone help jhow to remove this space? 有人可以帮助jhow删除这个空间吗?

使用br选择器选择所有<br/>标签

 $("br").remove();

You can remove <br> using CSS or jquery. 您可以使用CSS或jquery删除<br>

CSS Code CSS代码

#YourContainer br {
  display: none;
}

Or Using jQuery 或者使用jQuery

$('br').remove();

You can use: 您可以使用:

  $("br").remove();

or more specific by target only <br> inside your #CCcontainer div if you don't want to remove all the <br> in the page like above code then: 或目标更具体的只有<br>您的内部#CCcontainer格,如果你不想删除所有<br>中然后像上面的代码页:

$('#CCcontainer br').remove();

and you can also use hide function for remove class='remove' tag for that only assign class to br tag 并且您还可以使用隐藏功能删除class ='remove'标记,仅将该类分配给br标记
and call this function as per your requirement $(".remove").hide(); 并根据您的要求调用此函数$(“。remove”)。hide();

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

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