In node.html.twig, I want to show a field when I click on it, as what the Field Value Loader (Show field on click) module does, but this module doesn't have releases for Drupal 8.
How can I do this?
In node.html.twig, I want to show a field when I click on it, as what the Field Value Loader (Show field on click) module does, but this module doesn't have releases for Drupal 8.
How can I do this?
node.html.twig
<div class = "field-something">
{{ content.field_something.value }}
</div>
<div class = "show">
Show
</div>
custom.js
(function ($) {
$('.field-something').hide();
$('.show').show();
$('.show').click(function(){
$('.field-something').fadeIn(2000);
$('.show').hide();
});
}(jQuery));
Your Theme's style.css
.field-something { float: left; padding-right: 5px; }
.show { color: blue; cursor: pointer; display: none; }
var notificationList = false;
$('.show').click(function(){
if(notificationList) {
notificationList = false;
$('.field-something').hide();
} else {
notificationList = true;
$('.field-something').show();
}
});