php - Need to change from get ByID to ClassName (Javascript) -
it working when getelementbyid. when change classname, doesn't work.
the reason why going class name because there many looping (php) ticket in page ordered ticket number. , when "view" clicked specif ticket, show full message on it.
of course, can't multiple duplicate "id" here. , need change class name only. help, please.
<div id="menutiket"> <span style="padding:10px; background:yellow; float:right;"> <a href = "javascript:void(0)" onclick ="document.getelementsbyclassname('light').style.display='block'; document.getelementsbyclassname('fade').style.display='block'; ">tiket baru</a></span></div> <!--black overlay--> <div id="fade" class="fade overlaymessage" onload="initdynamicoptionlists()"></div> <!--pop div--> <div id="light" class="light popupboxmesage"> <span style="position: absolute; top: 11px; right:1px; color:white;" id="closeblocked"> <a style="color:green; text-decoration:none; background:white; padding:10px;" href = "javascript:void(0)" onclick ="document.getelementsbyclassname('light').style.display='none'; document.getelementsbyclassname('fade').style.display='none'"><b> x </b></a> </span> </div>
css:
<style type="text/css"> .overlaymessage{ display: none; position: fixed; top: 0%; left: 0%; width: 100%; height: 100%; background-color: black; z-index:10000001; -moz-opacity: 0.5; opacity:.45; filter: alpha(opacity=40); } .popupboxmesage { display: none; position: fixed; top: 0; left: 0; bottom:0; right:0; border: solid 10px darkseagreen; background-color: greenyellow; width:70%; height:400px; z-index:10000002; overflow: auto; padding: 1% 2% 12px 2%; margin: auto; } /* css document */ </style>
it's getelementsbyclassname
(notice 's' after 'element') because returns more 1 element. can have multiple elements in dom same class.
the result collection, , can see specific item :
var elements = document.getelementsbyclassname("class"); var firstelement = elements[0];
Comments
Post a Comment