Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove <br /> after image using jquery or javascript

Tags:

jquery

I have...

<td align="right" vAlign="top">
<img src="test/test.gif" width="1" height="4" border="0"><br />
Number<font color="#CC0000">*</font>:
</td><td></td><td>

How do I ditch that hanging <br /> with jquery? I've tried a ton of examples here ,but nothing works. Any ideas?

like image 663
Geek Grid Avatar asked Dec 13 '12 21:12

Geek Grid


People also ask

How to add html controls dynamically using jQuery?

Create Dynamic Controlsappend() event with the control in which you want to add some dynamic controls and in that append event you need to write the HTML code similar to what you might have written in the body section and this will work for you, for example: <script> $(document). ready(function () {

How to add dynamic DIV using jQuery?

jQuery example to dynamically add a div on page In this example, we have a div with id board and a button to add new divs into this board. In $(document). ready() we have bound an event listener to click event, which means when the user will click on this button, new divs will be created and added into the board.


2 Answers

Have you tried this?

$("img").next("br").remove();
like image 145
VisioN Avatar answered Sep 24 '22 02:09

VisioN


Assuming you want to remove all <br> that follow an <img> you can use this:

$('img + br').remove()

If you prefer it to apply only to those inside a <td>:

$('td > img + br').remove()
like image 22
ThiefMaster Avatar answered Sep 26 '22 02:09

ThiefMaster