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");
});
精彩评论