简体   繁体   中英

Hide/Show button for HTML email

I am generating an HTML email using a java program and need a Hide/Show button for some queries, What would be an ideal approach for this?, shd i call a javascript from java program to do the same?.

I have a javascript module to do the show/hide feature but not sure how to integrate this to a java program.

Thanks..

Javascript is completely independent from any server-side framework or language, such as Java.

If you want to show or hide an HTML element on a page, try the following JS code:

document.getElementById("id").style.display = 'none';

And then, when you generate the HTML email using Java, include the queries you want to hide in a <div> with a specified ID.

Add a class to your generated html tags and use css to control the visibility and other styling.

<style type='text/css'>
    .hid {display: none;}
</stle>

<div class='query1 hid'>...</div>
<div class='query2'>...</div>
<div class='query1 hid'>...</div>

Then update your javascript to manipulate the class attribute.

//in jQuery...
$("btn1").click(function() {
    $(".query2").addClass("hid");
    $(".query1").removeClass("hid");
});

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM