user3067524
user3067524

Reputation: 527

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. 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?

Upvotes: 14

Views: 45882

Answers (4)

damon
damon

Reputation: 65

and you can also use hide function for remove class='remove' tag for that only assign class to br tag
and call this function as per your requirement $(".remove").hide();

Upvotes: 1

Felix
Felix

Reputation: 38112

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:

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

Upvotes: 8

Monirul Islam
Monirul Islam

Reputation: 935

You can remove <br> using CSS or jquery.

CSS Code

#YourContainer br {
  display: none;
}

Or Using jQuery

$('br').remove();

Upvotes: 13

Pranav C Balan
Pranav C Balan

Reputation: 115242

Use br selector for selecting all <br/> tag

 $("br").remove();

Upvotes: 36

Related Questions