Reputation: 6485
Using Jquery, how do I find and hide elements like this?
<p>MyHeader</p>
The only identifier is MyHeader here, so trying to find elements that exactly match this and hide them.
Edit: I don't have a choice to add ids or class selectors, that would have made life easier :-) anyway, I found jquery contains seems to be of help!
Upvotes: 3
Views: 90
Reputation: 2989
One way to do this is to add a class to the p tag.
So you would do something like this:
<p class="myClass">MyHeader</p>
Then you can hide that using the following jQuery
$(".myClass").hide()
Upvotes: 1
Reputation: 1987
Add id or class definition to the p tag
HTML
<p class="header">MyHeader</p>
JQUERY
$('.header').hide();
Upvotes: 0
Reputation: 1146
Jquery API has a Contain function:
http://api.jquery.com/category/selectors/content-filter-selector/
This is an example:
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<div>John Resig</div>
<div>George Martin</div>
<div>Malcom John Sinclair</div>
<div>J. Ohn</div>
<script>
$("div:contains('John')").css("text-decoration", "underline");
</script>
</body>
</html>
Upvotes: 1