javascript - Show hidden div, why code works in FF/Chrome but NOT in IE9? -


consider following example:

<html> <head> </head> <body> <style type="text/css"> .hide {     display: none; } </style> <button style="width:200;height:20;background-color:#b4cfec;font: bold 10px verdana" onclick="document.getelementbyid('cust_class').classlist.remove('hide');" >customer dimension</button> <div class="hide" id="cust_class">"lorem ipsum dolor sit amet, consectetur adipisicing elit, sed eiusmod tempor incididunt ut labore et dolore magna aliqua. ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</div> </body> </html> 

i using document.getelementbyid('id').classlist.remove('class'); function here. should use different function? microsoft only?

this hideous, removes specified class, retaining others:

onclick="document.getelementbyid('cust_class').setattribute('class', document.getelementbyid('cust_class').getattribute('class').replace('hide', ''));" 

as commented, ie9 doesn't support classlist, can either shim it, or fall jquery, handle browser compatibility. jquery equivalent code:

$("#cust_class").removeclass("hide"); 

however, if hide class used nothing more toggling visibility, simplify more:

$("#cust_class").hide(); $("#cust_class").show(); 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -