http://westmark.finalsite.com/
Look at the Facebook section. Given that HTML, is there anyway to truncate the text at a certain character amount? I know about substr and everything, but given the HTML with the dynamic-valued spans in the beginning/end…how should I approach this?
I’m using jQuery.
could you use a jQuery plugin like this one
http://mikeking.io/succinct/ ?
I’d rather not . I’d prefer justa few lines of jQuery, instead of a plugin.
The actual plugin is like 50 lines, we could probably pull your few lines of jQuery out of there…
/*
* Copyright (c) 2014 Mike King (@micjamking)
*
* jQuery Succinct plugin
* Version 1.1.0 (October 2014)
*
* Licensed under the MIT License
*/
/*global jQuery*/
(function($) {
'use strict';
$.fn.succinct = function(options) {
var settings = $.extend({
size: 240,
omission: '...',
ignore: true
}, options);
This file has been truncated. show original
1 Like
This file has been truncated. show original
I see what you did there, Discourse.
Does that work though - would the plugin ignore the HTML tags and just grab the raw text (ignoring the HTML)?
Can’t really see if the demo is working to my needs or not.
Yeah, not sure if it would ignore tags inside the element or not…
I’m actually about to solve this same problem. Thanks for this.
Would straight CSS work? Do you have a specific width/height to abide by?
1 Like
nm, seems that won’t work with display: table.
1 Like
No width/height; just basically I don’t want a 1000 word post messing crap up.
The problem with text-overflow is it doesn’t fit my situation unfortunately .
system
Closed
October 22, 2015, 12:50am
12
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.