Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide text which is not inside HTML tag?

<div class="padd10_m">
<a href="http://www.caviarandfriends.com/job_board/user-profile/admin/" class="grid_view_url_thing1">admin</a> 
US <img src="http://www.caviarandfriends.com/job_board/wp-content/themes/PricerrTheme/images/flags/us.png">                
</div>

In the above code I want to hide "US" word. I hide that image after US but unable to find the way to hide this "US" word. what could be the code to hide it?

like image 330
Rasika Avatar asked Sep 27 '16 07:09

Rasika


People also ask

How do you make text not visible in HTML?

Methods to Hide from Screen Readers To hide text from a screen reader and hide it visually use the hidden attribute. You can also use CSS to set display: none or visibility: hidden to hide an element from screen readers and visually.

How do I hide text messages without tags?

visibility:hidden , color:transparent and text-indent will do this.

How do I hide text in an element?

If the point is simply to make the text inside the element invisible, set the color attribute to have 0 opacity using a rgba value such as color:rgba(0,0,0,0); clean and simple. Save this answer.


1 Answers

Something like this?

.padd10_m {
  font-size: 0px;
}
.padd10_m > * {
  font-size: 14px;
  /* Apply normal font again */
}
<div class="padd10_m">
  <a href="http://www.caviarandfriends.com/job_board/user-profile/admin/" class="grid_view_url_thing1">admin</a> US
  <img src="http://www.caviarandfriends.com/job_board/wp-content/themes/PricerrTheme/images/flags/us.png">
</div>

Working fiddle

Or

If you want to go with JavaScript (I don't see why though), Here is the solution:

var pad = document.querySelector('.padd10_m');
Array.prototype.forEach.call(pad.childNodes, function(el) {
  if (el.nodeType === 3) {   // check if it is text node
    pad.removeChild(el);     // remove the text node
  }
});
<div class="padd10_m">
  <a href="http://www.caviarandfriends.com/job_board/user-profile/admin/" class="grid_view_url_thing1">admin</a> US
  <img src="http://www.caviarandfriends.com/job_board/wp-content/themes/PricerrTheme/images/flags/us.png">
</div>
like image 67
Mr_Green Avatar answered Sep 29 '22 10:09

Mr_Green