j0hnik,
исчез 1 блок из-за search(/>/) , исчезли алерты по картинкам.
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(function() {
var size = 30,
newsContent = $(".gkTabsItem.active p"),
newsText = newsContent.text();
newsContent.find("img").on("click", function() {
alert(123);
})
/* if (newsText.length > size) {
newsContent.contents().filter(function() {
return this.nodeType == 3
}).remove();
newsContent.append(newsText.slice(0, size) + " ...")
}*/
$(".gkTabsItem.active p").each(function(){
var text = $(this).html();
if(text.length> 30+text.search(/>/)) {
$(this).html(text.substr(0,30+text.search(/>/))+"...");
}
});
});
</script>
</head>
<body>
<div class="gkTabsItem active">
<p><img alt=">" src="https://javascript.ru/forum/images/ca_serenity/misc/logo.gif" >Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum
Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum
</p>
</div>
<div class="gkTabsItem active">
<p><img src="https://javascript.ru/forum/images/ca_serenity/misc/logo.gif" >это второй блок, а где первый? Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum
Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum
</p>
</div>
</body>
</html>