Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7656687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:49:53+00:00 2026-05-31T12:49:53+00:00

I am trying to remove <br /> tag from wordpress native gallery through jquery

  • 0

I am trying to remove <br /> tag from wordpress native gallery through jquery and have tried lots of way but none of them works..

I have tried few codes below (note: I have changed in my theme file <br style="clear:both" /> to <br class="clearboth" /> also I have deregisterd jquery and registed with googleapis for my theme.

<script>$('br.clearboth').html();</script>

and

<script>
(function($) {
    $.strRemove = function(theTarget, theString) {
        return $("<br/>").append(
            $(theTarget, theString).remove().end()
        ).html();
    };
})(jQuery);
</script>

I am placing this code exactly at the top of the entry div of the wordpress. May be I am placing script at wrong place. Nothing working and none of this removing any br tag from gallery section…

Actual source code I am getting as below..I have tried js as you guyz said but its not working somehow you can see in source code the is still there.

<!--BEGIN: Single Post-->
    <article class="post-866 gallery type-gallery status-publish hentry mp_gallery" id="post-866">

        <div class="entry">

        <!--[this js i have added here]-->
        <script>
            $("br.clearboth").remove();
        </script>


            <style type='text/css'>
                #gallery-1 {
                    margin: auto;
                }
                #gallery-1 .gallery-item {
                    float: left;
                    margin-top: 10px;
                    text-align: center;
                    width: 33%;
                }
                #gallery-1 img {
                    border: 2px solid #cfcfcf;
                }
                #gallery-1 .gallery-caption {
                    margin-left: 0;
                }
            </style>
            <!-- see gallery_shortcode() in wp-includes/media.php -->
        <ul id='gallery-1' class='gallery galleryid-866 gallery-columns-3 gallery-size-thumbnail clearfix'><li class='gallery-item'>
                <p class='gallery-icon'>
                    <a href='http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0432.jpg' title='DSC_0432'><img width="190" height="110" src="http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0432-190x110.jpg" class="attachment-thumbnail colorbox-866" alt="Lorem ipsum dolor sit amet," title="DSC_0432" /></a>
                </p>
                    <p class='wp-caption-text gallery-caption'>

                    Lorem ipsum dolor sit amet, 
                    </p></li><li class='gallery-item'>
                <p class='gallery-icon'>
                    <a href='http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0503.jpg' title='DSC_0503'><img width="190" height="110" src="http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0503-190x110.jpg" class="attachment-thumbnail colorbox-866" alt="Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium" title="DSC_0503" /></a>
                </p>
                    <p class='wp-caption-text gallery-caption'>
                    Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium
                    </p></li><li class='gallery-item'>
                <p class='gallery-icon'>
                    <a href='http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0516.jpg' title='DSC_0516'><img width="190" height="110" src="http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0516-190x110.jpg" class="attachment-thumbnail colorbox-866" alt="DSC_0516" title="DSC_0516" /></a>

                </p></li>

                <br class="clearboth" />

                <li class='gallery-item'>
                <p class='gallery-icon'>
                    <a href='http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0657.jpg' title='DSC_0657'><img width="190" height="110" src="http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0657-190x110.jpg" class="attachment-thumbnail colorbox-866" alt="Most beautiful face evern catched before" title="DSC_0657" /></a>
                </p>
                    <p class='wp-caption-text gallery-caption'>
                    Most beautiful face evern catched before
                    </p></li><li class='gallery-item'>
                <p class='gallery-icon'>
                    <a href='http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0658.jpg' title='DSC_0658'><img width="190" height="110" src="http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0658-190x110.jpg" class="attachment-thumbnail colorbox-866" alt="Beauty queen on the earth and praising pain was born and But I must explain to you how all this" title="DSC_0658" /></a>

                </p>
                    <p class='wp-caption-text gallery-caption'>
                    Beauty queen on the earth and praising pain was born and But I must explain to you how all this
                    </p></li><li class='gallery-item'>
                <p class='gallery-icon'>
                    <a href='http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0676.jpg' title='DSC_0676'><img width="190" height="110" src="http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0676-190x110.jpg" class="attachment-thumbnail colorbox-866" alt="Handsome Guy will Look after you :)" title="DSC_0676" /></a>
                </p>
                    <p class='wp-caption-text gallery-caption'>
                    Handsome Guy will Look after you :)
                    </p></li>

                    <br class="clearboth" />

                    <li class='gallery-item'>

                <p class='gallery-icon'>
                    <a href='http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0677.jpg' title='DSC_0677'><img width="190" height="110" src="http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0677-190x110.jpg" class="attachment-thumbnail colorbox-866" alt="Dashing Guy who is looking for a gal" title="DSC_0677" /></a>
                </p>
                    <p class='wp-caption-text gallery-caption'>
                    Dashing Guy who is looking for a gal
                    </p></li><li class='gallery-item'>
                <p class='gallery-icon'>
                    <a href='http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0125.jpg' title='DSC_0125'><img width="190" height="110" src="http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0125-190x110.jpg" class="attachment-thumbnail colorbox-866" alt="DSC_0125" title="DSC_0125" /></a>
                </p></li><li class='gallery-item'>

                <p class='gallery-icon'>
                    <a href='http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0416.jpg' title='DSC_0416'><img width="190" height="110" src="http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0416-190x110.jpg" class="attachment-thumbnail colorbox-866" alt="One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin." title="DSC_0416" /></a>
                </p>
                    <p class='wp-caption-text gallery-caption'>
                    One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. 
                    </p></li>

                    <br class="clearboth" />

                    <li class='gallery-item'>
                <p class='gallery-icon'>
                    <a href='http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0431.jpg' title='DSC_0431'><img width="190" height="110" src="http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0431-190x110.jpg" class="attachment-thumbnail colorbox-866" alt="DSC_0431" title="DSC_0431" /></a>
                </p></li>

                <br style='clear: both;' />
            </ul>

    </article>

    <!--END: Single Post-->
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:49:55+00:00Added an answer on May 31, 2026 at 12:49 pm

    If you are trying to remove br tags from the DOM, you can do this:

    $("br").remove();
    

    If you only want of a specific class, do this:

    $("br.clearboth").remove();
    

    If you only want to remove br tags from a specific node, do this:

    $("#someId br.clearboth").remove();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to remove all but the first child component from a Java Container.
I am trying to remove following tag from string. [caption id=attachment_9 align=alignleft width=137 caption=test][/caption]
I'm trying to remove a class from a HTML tag along with adding a
i am trying to remove parent tag, but removing parent tag should not remove
I'm trying to remove everything from a string that is NOT an html tag
I am trying to remove certain links depending on their ID tag, but leave
Hi I am trying to remove the object tag from my HTML content using
I'm trying to remove the last separator (normally a <br/> tag but I changed
I'm trying to remove a color from a picture imported (JPG) in Flash CS4
I'm trying to remove a class attribute from an element and add the class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.