Solved

hiding a html tag on page load with JavaScript or jQuery

Posted on 2016-07-16
2
48 Views
Last Modified: 2016-07-16
I have this fiddle which contains html, css and jquery code.

http://jsfiddle.net/w71fywwx

In the HTML portion of my fiddle I have this code:


    <div id="Div1">
        <span id="Span1"></span>
        <div id="Div2">
        </div>
        <span id="Span2"></span>
        <div id="Div3">
        </div>
    </div>

Open in new window


I'm trying to hide the span tag with this id="Span1 on page load from completely being rendered in the browser.

If you run this fiddle in Google Chrome and look at the html rendered inside Div1 it looks like this:

running in chrome
I noticed the html for the span tag rendered in google chrome is this.

<span id=Span1" style="display: none;"></span>

My fiddle just hide its visibility but I actually want to keep the span tag from being completely rendered not just made invisible.  

So this span wasn't hidden. just some css was added to it.

Is there a way to use JavaScript or jQuery to completely hide this Span tag so it is not rendered in the web browser?
I don't want just the display:none tag added to it like my fiddle is currently doing.
0
Comment
Question by:maqskywalker
2 Comments
 
LVL 9

Accepted Solution

by:
Moussa Mokhtari earned 500 total points
ID: 41714841
@maqskywalker
remove it like this
$("#Span1").remove();
0
 
LVL 1

Author Closing Comment

by:maqskywalker
ID: 41714870
Thanks
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question