please look this code : CODE
this code work in jsfiddle.net but not work on local
js code in local ,
this code show and hide more less text
<script type="text/javascript" src="jquery-1.8.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var maxheight=118;
var showText = "More";
var hideText = "Less";
$('.textContainer_Truncate').each(function () {
var text = $(this);
if (text.height() > maxheight){
text.css({ 'overflow': 'hidden','height': maxheight + 'px' });
var link = $('<a href="#">' + showText + '</a>');
var linkDiv = $('<div></div>');
linkDiv.append(link);
$(this).after(linkDiv);
link.click(function (event) {
event.preventDefault();
if (text.height() > maxheight) {
$(this).html(showText);
text.css('height', maxheight + 'px');
} else {
$(this).html(hideText);
text.css('height', 'auto');
}
});
}
});
});
</script>
htm code :
<div class="textContainer_Truncate">
<p>content<br>
hello<br>
hello<br>
hello<br>
hello<br>
hello<br>
hello<br>
hello<br>
hello<br>
hello<br>
hello<br>
hello<br>
hello<br>
hello<br>
hello<br>
hello<br>
hello<br>
</p>
</div>
content of folder :
index.htm and jquery-1.8.2.min.js
how to use this code on local ?
I’ve tried to replicate what you have done and found that it’s working fine with no error.
consider to download this solution (a folder contains an index.html page along side with jquery 1.8.2.js file).
maybe you have made something extra
Test Project
Update: I’ve noticed something when copying your code, there is an extra questionmark in your code, look at the following picture