<div class="summary" id="para1">
<p>my paragraph starts the same way bla bla bla bla bla bla bla bla bla bla bla bla bla</p>
</div>
<div class="content" id="para2">
<p>my paragraph ztarts the same way bla bla bla bla bla bla bla bla bla bla bla bla bla</p>
</div>
JavaScript
// get text from paragraph 1
var text1 = document.getElementById("para1").innerHTML;
// get text from paragraph 2
var text2 = document.getElementById("para2").innerHTML;
// get first 100 caracters from paragraph 1
var lastTwentyText1 = text1.substr(0, 100);
// get first 100 caracters from paragraph 2
var lastTwentyText2 = text2.substr(0, 100);
//if the first 100 caracters of the paragraphs are the same
if ( lastTwentyText1 == lastTwentyText2 ) {
// then it hides the first paragraph
document.getElementById('para1').style.display="none";
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.