[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

jquery cell size limit

Posted on 2014-08-13
3
Medium Priority
?
132 Views
Last Modified: 2014-08-13
Hi,

I have a table with multiple cells, i want the cells that have more than 25 characters, appears only the first 25 characters and a word that says more info..., then when the user press the button, appear the rest of the information of the cell, any idea?
0
Comment
Question by:joyacv2
  • 2
3 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40258751
http://jsfiddle.net/GaryC123/78Lp2w5w/

$("td").each(function () {
    if ($(this).text().length > 25) {
        $(this).html($(this).text().substr(0, 25) + "<span>...more&nbsp;info</span><p>" + $(this).text().substr(25) + "</p>")
    }

})
$(document).on("click", "td span", function () {
    $(this).hide()
    $(this).next().css("display", "inline").show()
})

Open in new window

0
 
LVL 1

Author Comment

by:joyacv2
ID: 40258849
Hi,

Can you check your jsFiddle address?
0
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 40258859
I think jsfiddle is going a bit doolally

http://jsfiddle.net/GaryC123/78Lp2w5w/3/
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question