javascript - Code not working in IE to hide and unhide Divs -
i'm no js asn code i'm using colleague put me , works fine in chrome isn't playing nice in ie.
the code allow me have list can click show hidden div , when click link in list hide last div , unhides last clicked etc.
here js
function hideclass(id){ $('.objections').addclass('hide'); $('#'+id+'_container').removeclass('hide'); }
and have in html
onclick="hideclass(this.id)"
is there anyway alter work in ie?
as said, i'm not @ js html css have no idea start
without seeing code it's hard know what's failing. guessed @ doing , came basic code, worked in ie me. however, ie did block scripts , had click allow. watch that.
function hideclass(id) { $('.objections').addclass('hide'); $('#' + id + '_container').removeclass('hide'); }
.hide { opacity: 0; }
<!doctype html> <html> <head> <meta charset="utf-8"> <title>test</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> </head> <body> <div id="myid" class="objections" onclick="hideclass(this.id)"> <h1>i object!</h1> </div> <div id="myid_container" class="hide"> <h1>can see me now?</h1> </div> </body> </html>
since using jquery though, code bit cleaner:
function hideclass(div) { $(div).hide(); $('#' + div.id + '_container').show(); }
<!doctype html> <html> <head> <meta charset="utf-8"> <title>test</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> </head> <body> <div id="myid" class="objections" onclick="hideclass(this)"> <h1>i object!</h1> </div> <div id="myid_container" style="display:none"> <h1>can see me now?</h1> </div> </body> </html>
Comments
Post a Comment