2

In the following div:-

<div>
     My Text that needs to be hidden 
    <span style="font-size: 21px">Other text Other things</span>
</div>

I just want to hide the text My Text that needs to be hidden. Is it possible?

2
  • 5
    possible duplicate of Hide text node in element, but not children Commented Aug 25, 2014 at 18:29
  • 1
    Basically the question doesn't have an obvious search text for it. May be that's how I missed it. Commented Aug 25, 2014 at 19:41

2 Answers 2

3

Html:

<div>
    <span id="mySpan" >My Text that needs to be hidden</span> // Add a span with a id
    <span style="font-size: 21px">Other text Other things</span>
</div>

JQuery:

$(document).ready(function(){
    $('#mySpan').css('display', 'none');
});
Sign up to request clarification or add additional context in comments.

Comments

2
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("p").hide("slow",function(){
      alert("The paragraph is now hidden");
    });
  });
});
</script>
</head>
<body>

<button>Hide</button>
<div>
     <p>My Text that needs to be hidden </p>
    <span style="font-size: 21px">Other text Other things</span>
</div>
</body>
</html>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.