JQuery truncate and reveal -


I am trying to create an effect on my website, I have a container of information at the top of the page, acting As a header for this specific page, my 'header' item has some text and a bigger image, but this lesson needs to be shortened in certain characters.

HTML

    

Code> & lt; Div class = "container" & gt; & Lt; Div id = "mytext" class = "text" & gt; & Lt; H1 & gt; Household Advertising & lt; / H1> Door Seat Amet, The Persector Adipisive Elite has worked on a large scale to reach now. There is a very easy and easy way to get more information about you. EuIdom Portter is used by Annexe Favigate, Trepece NEC Special Puter, Teles Fret Arch, Yut Ultra Magna Fellis A.C. We all work on a large scale, but always like. During custom fringle lounculation, suppliers can be used easily. Integer for integer, ID Congo Epsom If you can already get any type of information for any time, or tell me what I am doing, besides, also for me One major theme is Cubatur Eusemod, Dollar in Roanoke Vouchurele, Leo Auto Commodo Orsi, ID Poolwinner Felis Begus Lecce. & Lt; A href = "#" id = "detail-div" & gt; Expand & lt; / A & gt; & Lt; / Div & gt; & Lt; Div class = "image" & gt; Image goes here & lt; / Div & gt; & Lt; / Div & gt;

css

 . Container {width: 500px; Height: 300px; Border: Solid 1px black; Status: Relative; } .image {background: # 00b3f0; Line-height: 300px; Art color; Width: 50%; Text-align: center; } .text {color: black; Height: 100%; Status: Completed; Correct: 0; Background: # 00DD99; Max-width: 50%; } .text a {text-decoration: none; Display: inline-block; Background: white; Art color; Padding: 2px 5px; }   

JQuery

  var expand_btn = document.getElementById ('expand-div'). External HTML; Var long_title = document.getElementById ('mytext'). InnerHTML; Var short_title = jQuery.trim (long_title) .substring (0, 240) .split ("") .Slice (0, -1). Include (""); Document.getElementById ('MyText'). InnerHTML = short_title + '-' + expand_btn; Click $ ("# Expand-div") (function (event) {event.preventDefault (); text_div = $ (this) .closest ('div'); div_width = parseInt (text_div.css ('max-width' ("Max-width": "100%"} "slow"); document.getElementById ('expand-' ("max-width": "50%"}, "slow"); document.getElementById (' Expand-div '). InnerHTML =' expansion ';}});   

I used to show that kind of effect, but I have never done the best by writing JQuery and When I tried to change between the texts, maybe I made mistakes for myself Ideally, I want to animate the trunk effect, but this is not necessary.

It should make the property very easy, it will not work on some older browsers, though.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -