Skip to main content

Split Text into Lines - SplitLines | Free jQuery Plugins

SplitLines is a lightweight jQuery plugin which allow you to split block of text into multiple lines using specific html tag(s) and defined width & line heightSplitLines ( $.splitLines() ) is a jQuery plugin that splits new lines of wrapped text into their own HTML elements, allowing you to animate or operate on each line individually. Works with nested HTML tags as well.

splitLines() takes a block of text and splits it up into separate lines based on the width of the box or a width passed to the function.



Requirements
jQuery 1.4.2 or later


How to Split Text By Lines
Include required libraries on page.

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="jquery.splitlines.js"></script>


HTML:
Below is the sample text which need to split into lines.

<div id="mycontent">
    This is an <strong>example</strong> of some long text
    that we want to split into lines.
</div>

 
Javascript:

Below is the sample Function used to split long text into lines.

$(function() { 
 $('#mycontent').splitLines({
    tag: '<div><span class="someClass">', //Set the HTML tag to wrap the lines in
    width: 200, // Set width to the text lines
    keepHtml: true // allow / don't allow html in element.
 });
});


Result:

<div id="mycontent">
    <div><span class="someClass">This is an</span></div>
    <div><span class="someClass"><strong>example</strong> of</span></div>
    <div><span class="someClass">some long</span></div>
    <div><span class="someClass">text that we</span></div>
    <div><span class="someClass">want to split</span></div>
    <div><span class="someClass">into lines.</span></div>
</div>


 

Comments

Popular posts from this blog

Symbols Used in Excel Formula | The purpose of Symbols in Excel Formula

Following symbols are used in Excel Formula. They will perform different actions in Excel Formulas and Functions. Each of these special characters have used for different purpose in Excel. Symbol Name Description = Equal to Every Excel Formula begins with Equal to symbol (=). Example: = B1+B6 () Parentheses All Arguments of the Excel Functions specified between the Parentheses. Example: =COUNTIF ( B1:B5,5 ) () Parentheses Expressions specified in the Parentheses will be evaluated first. Parentheses changes the order of the evaluation in Excel Formula. Example:   =25+ ( 35*2 ) +5 * Asterisk Wild card operator to to denote all values in a List. Example:   =COUNTIF(B1:B5,” * “) , Comma List of the Arguments of a Function Separated by Comma in Excel Formula. Example:   =COUNTIF(B1:B5 , “>” &C1) & Ampersand Concatenate Operator to connect two strings into one in Excel Formula. Example:   =”Total: “ & SUM(C2:C25) $ Dollar Makes Cell Reference as Absolute in Excel Formula. Exam

How to create a Barcode Using PHP Barcode 128 Generator

A barcode is an optical, machine-readable, representation of data, the data usually describes something about the object that carries the barcode.We will use PHP to generate Barcode in this tutorial. In this script, we are using coding which will generate barcodes in barcode format Code 128 . First, we will create index.php which will ask for the user input for which Barcode has to be created PHP Barcode Generator <fieldset><legend>Detail Informations</legend><form action="createbarcode.php" method="post"><b>Enter Your Code </b><input name="barcode" type="text" /><input type="submit" value="Create Barcode" /></form></fieldset> Now we will create createbarcode.php which will call function from Barcode code128 class for creating barcode <? php include('barcode128.php'); // include php barcode 128 class // design our barcode display echo

Get current filename with first parameter(Query String) from URL using PHP function

Today eabhyas come up with a Query String function. This function is useful to get the Query String from URL. This Function is used to get current filename with first parameter(Query String) from URL using PHP function . Function: function rns_QueryString_first($incomingURL){     preg_match('/[^&]+/', $incomingURL, $match);     return $outgoingURL = $match[0]; } Example: $path="property_add?id=3&aa=aa&b=123"; define('RNSFIFQ', rns_QueryString_first($path)); echo RNSFIFQ; Output: property_add?id=3