What 's wrong with this code ?
4 posters
Page 1 of 1
What 's wrong with this code ?
I have 2 images ( image 1 and image 2 )
click on image 1 and image 2 on/off alternately
but it does not work ?
click on image 1 and image 2 on/off alternately
but it does not work ?
- Code:
$(function(){
$("body").append('<div class="vietkeybutton">
<img src="http://2img.net/s/t/20/71/96/i_folder_new.gif" onclick="MyFunction();var img = document.getElementById("imgInfo");if (img.style.visibility === "hidden") img.style.visibility = "visible"; else img.style.visibility = "hidden";" />
<img id="imgInfo" src="https://upload.vstanced.com/images/2016/09/06/NQW.png" style="visibility:hidden" />
</div>')
});
Last edited by TamDonCo on September 6th 2016, 10:10 pm; edited 1 time in total
Re: What 's wrong with this code ?
try:
or better:
- Code:
function change_img(){
var img=document.getElementById("imgInfo");
img.style.visibility ==="hidden" ? img.style.visibility="visible" : img.style.visibility="hidden";
};
$(function () {
$("body").append('<div class="vietkeybutton"><img src="http://2img.net/s/t/20/71/96/i_folder_new.gif" onclick="change_img();"/><img id="imgInfo"src="https://upload.vstanced.com/images/2016/09/06/NQW.png" style="visibility:hidden"/></div>')
});
or better:
- Code:
function change_img(){
var img=document.getElementById("imgInfo");
img.style.visibility ==="hidden" ? img.style.visibility="visible" : img.style.visibility="hidden";
};
$(function () {
var a = '<div class="vietkeybutton"><img src="http://2img.net/s/t/20/71/96/i_folder_new.gif" onclick="change_img();"/><img id="imgInfo"src="https://upload.vstanced.com/images/2016/09/06/NQW.png" style="visibility:hidden"/></div>';
document.body.insertAdjacentHTML('beforeend', a);
});
Ch@lo Valdez- Forumember
- Posts : 138
Reputation : 50
Language : spanish
Re: What 's wrong with this code ?
Is this solved? If yes, please mark the topic with the solved topic icon.
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Re: What 's wrong with this code ?
Problem solved & topic archived.
|
Similar topics
» Code wrong??
» Code: Select Content for code box
» When i paste a long code via [code][/code] the page expands
» When I edited a message with a code "code" it adds a space
» help in this code . the effect on code > add button to Put under the colored writing
» Code: Select Content for code box
» When i paste a long code via [code][/code] the page expands
» When I edited a message with a code "code" it adds a space
» help in this code . the effect on code > add button to Put under the colored writing
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum