I am trying to achieve a show more/show less function on my product page, built with Elementor Page Builder. Kinda Like this with the fade also, but using JS.
I currently have this setup on my My Product Page . It's not quite what I want as the section is completely hidden and then is revealed on-click.
I have achieved this by doing the following:
I have then added the following custom CSS to this:
#hiddenBlock {
Display:none;
}
Then I've added some custom JS using another plugin as follows:
jQuery(document).ready(function( $ ){
$('#showBlock').click(function(e) {
e.preventDefault();
$('#hiddenBlock').fadeToggle("slow");
});
});
However, how would I go about achieving what I mentioned where the section can be partially viewed and then completely revealed on-click. I'd ideally like the button text to change also when its clicked, to say 'show less' or something.
Thanks in advance.
Can you using .toggle()
jQuery(document).ready(function( $ ){
$('#showBlock').click(function(e) {
$('#hiddenBlock').toggle();
e.preventDefault();
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.