I am trying to get a loop for a while inside each loop but this page creates crashes. Can be written in a manner? What I'm trying to do is to add an alipis when multiple overlapping text overflow within multiple elements become overflow.
HTML
& lt; Div class = "three call-three img-txt" & gt; & Lt; Div class = "txt-block" & gt; & Lt; Div class = "txt-entries" & gt; & Lt; Div class = "txt-entries-wrap" & gt; & Lt; P & gt; Household Advertising & lt; / P & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "txt-block" & gt; & Lt; Div class = "txt-entries" & gt; & Lt; Div class = "txt-entries-wrap" & gt; & Lt; P & gt; Household Advertising & lt; / P & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "txt-block" & gt; & Lt; Div class = "txt-entries" & gt; & Lt; Div class = "txt-entries-wrap" & gt; & Lt; P & gt; Household Advertising & lt; / P & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt;
JQUERY
$ (". Three-three-img-txt .txt-block") .each (function () {Var ph = $ (this) .find ('.txt-entries .txt-entries-wrap'); var p = $ (this) .find ('.txt-entries .txt-entries-wrap P' ); Var divh = $ (this) .find ('.txt-entries'). Height (); while ($ (ph). OuterHeight ()> gth) {$ (p) .text (function (index, text) ) {Return text.replace (/ \ W * \ s (\ s) * $ /, '...');});}}); It appears that you need a loop through each .txt-block
, then another loop through each
.txt-entries
. If this is necessary then this case: $ (document) ) .ready (function () ($ (".txt-block"). Each (function () {$ (this) .find ('.txt-entries'). Each (function () {var ph = $ ( This) .find ('.txt-entries-wrap'); var p = $ (this) .find ('.txt-entries-wrapp'); var divh = $ (this) .height (); if ($ (PH) Outer outer ()> divh) {$ (p) .text (function Dex, text) {return text.replace (/ \ W * \ s (\ s) * $ /, '...')}}}}}};});});
No comments:
Post a Comment