[英]How To Add a button to Show/ Hide the image in webview
public static String getShowOrHideImage() {
return "\n<button type='button' onclick='return showImage();' id='show-hide-button'
class= 'hide-or-show-text'>Hide Image</button>";
}
The JavaScript function JavaScript function
function showImage() {
var images = document.getElementsByTagName("img");
for (i = 0; i < images.length; i++) {
if (images[i].style.display === "none") {
images[i].style.display = "block";
document.getElementById("show-hide-button").innerHTML = 'Hide Image';
} else {
images[i].style.display = "none";
document.getElementById("show-hide-button").innerHTML = 'Show Image';
}
}
}
end snippet结束片段
The function itself not invoking. function 本身没有调用。
The Problem is with the type.问题在于类型。
public static String getShowOrHideImage() {
return "\n<button onclick='showImage()' id='show-hide-button' class= 'hide-or-show-text'>Hide Image</button>";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.