- #How to show hidden text in class using jquery update#
- #How to show hidden text in class using jquery code#
- #How to show hidden text in class using jquery download#
#How to show hidden text in class using jquery code#
See the below for a version of the above code that should work fine. The reason as to why your above code isn’t working correctly is due to how you have setup the element for the toggle event, instead of targeting specific elements by their class name or ID you really should be using some built into jQuery methods which help with situations like this. Any suggestions as to how I can get the text to change back on the second click or an explanation of why this code doesn’t work? toggle the display by clicking on button $('Show Map').insertBefore('.event-map') Here is the JQuery code I’ve written so far. Here is the html of the section in question ģ0-36 Belmont Street, Sutherland NSW 2232 I’m having problems changing the text back to ‘show’ if the user clicks on the hide map link. Clicking on the text will show the map and change the text to hide. I’ve got the show/hide function working and the text is initially set to show when the map is hidden. I want to toggle the text between show and hide depending on whether the map section is visible or not. If (content.length > config.I’m using JQuery to hide a map on the page and then insert a show/hide text link that, when clicked will reveal the that contains the map. Now instead of cutting and adding what function have cutted, function now cuts and shows this content at first and then when clicking “more” button it shows whole content. I´ve just modified your code becuase i had problems with html contents. This is useful if you want it to use with mobile phones and touchscreens. Now you just have to click on anywhere inside the “showmore” div and the teasertext will be shortened or will be enlarged. $(this).find('.shorten_txt p:first span.morecontent_txt').toggle() $(this).find('.shorten_txt p:first span.moreelipses').toggle() $(this).find(".shorten_txt p:first span.morecontent_txt").toggle() $(this).find(".shorten_txt p:first").html(html)
![how to show hidden text in class using jquery how to show hidden text in class using jquery](https://bomega.pl/wp-content/uploads/2021/03/fb_image-1768.png)
Var h = teaser.substr(showChar, con_length - showChar) Var con_length = parseInt(teaser.length) Var teaser = $(this).find('.shorten_txt p:first').html() you can do this above with every other element $(this).find('.shorten_txt p:first').removeClass('more_p').show() Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. If someone wants to use this plugin with more than one HTML-Element to show/hide and don’t want to click on a little button or something, here is my work around.
#How to show hidden text in class using jquery download#
Var html = c + '' + config.ellipsesText + ' ' + h + ' ' + config.moreText + '' Ĭode language: JavaScript ( javascript ) Download Click to download jQuery Shorten plugin Usage Step 1: Include the jQuery plugin in your HTMLĪgain: Many thanks to Viral Patel for this awesome Plugin! Var h = content.substr(config.showChars, content.length - config.showChars) Var c = content.substr( 0, config.showChars)
![how to show hidden text in class using jquery how to show hidden text in class using jquery](https://2.gravatar.com/avatar/0eae4d0dd6dc919ae00b9aba67388e4d?d=https:%2F%2Fgithub.githubassets.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png)
If($ this.hasClass( "shortened")) return Download Source Code Click here to download (ZIP, 2KB) jQuery Plugin Code Please check latest plugin code on GitHub. HTML tags are now parsed properly within text to preserve its uniformity while shorting the text.
#How to show hidden text in class using jquery update#
Var html = c + '' + ellipsestext+ ' ' + h + ' ' + moretext + '' Ĭode language: JavaScript ( javascript ) Online Demo Click here to view demo Update The above code is modified into jQuery plugin. Var h = content.substr(showChar -1, content.length - showChar) I've got the show/hide function working and the text is initially set to show when the map is hidden.
![how to show hidden text in class using jquery how to show hidden text in class using jquery](https://images-na.ssl-images-amazon.com/images/I/51tMepT-F%2BL._SX218_BO1,204,203,200_QL40_.jpg)
The extra text from the content is wrapped in this span and is hidden at time of page loading. Note the class “.morecontent span” is hidden. Code language: HTML, XML ( xml ) The CSS Below is the CSS code for our example. Proin blandit nunc sed sem dictum id feugiat quam blandit.ĭonec nec sem sed arcu interdum commodo ac ac diam. You can show 'Hide description' anchor tag when description is expanded. click again on the same 'showDescription' will hide the Description. Sed tristique pellentesque arcu quis tempor.Ĭonsectetur adipiscing elit. Click on 'showDescription' will show the description. Maecenas lobortis odio id sapien facilisis elementum.Ĭurabitur et magna justo, et gravida augue. Donec.ĭuis nisl nibh, egestas at fermentum at, viverra et purus. Quam ligula sodales orci, congue imperdiet eros tortor ac lectus.ĭuis eget nisl orci. Vestibulum laoreet, nunc eget laoreet sagittis,
![how to show hidden text in class using jquery how to show hidden text in class using jquery](https://14h9zobgf5e113fca2pv9gln-wpengine.netdna-ssl.com/wp-content/uploads/2020/05/optimisier-fiches-produits-sxo-1024x684.png)
Lorem ipsum dolor sit amet, consectetur adipiscing elit.