Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 726
user3067524 Avatar asked Feb 10 '14 15:02

user3067524


3 Answers

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();
like image 169
Felix Avatar answered Sep 21 '22 18:09

Felix


Use br selector for selecting all <br/> tag

 $("br").remove();
like image 35
Pranav C Balan Avatar answered Oct 31 '22 12:10

Pranav C Balan


You can remove <br> using CSS or jquery.

CSS Code

#YourContainer br {
  display: none;
}

Or Using jQuery

$('br').remove();
like image 13
Monirul Islam Avatar answered Oct 31 '22 11:10

Monirul Islam