I want to make the click of a button run a javascript function that will change an html tag.
At first I was thinking of just having the javascript change class name and have the css hide anything with the other name, but that wasn't working... any suggestions for that because that seems simpler to me.Code:<script type="text/javascript"> var type; var data = new Array(); function getCookie(NameOfCookie) { if (document.cookie.length > 0) { begin = document.cookie.indexOf(NameOfCookie+"="); if (begin != -1) // Note: != means "is not equal to" { begin += NameOfCookie.length+1; end = document.cookie.indexOf(";", begin); if (end == -1) end = document.cookie.length; return unescape(document.cookie.substring(begin, end)); } } return null; } function getData(){ //code to grab innerHTML of each p with class title "exceprt" } function changeTag() { if (type.length == 0) { type = getCookie("mode"); } if(type == "list) { type = "grid"; document.getElementsByClassName('excerpt').innerHTML = ""; } else { type = "list"; //to place code to replace innerHTML with string stored in data } } </script> <p class='excerpt'> <?php if (function_exists('smart_excerpt')) smart_excerpt(get_the_excerpt(), 55); ?> </p>
Please help.