Getting javascript to work…
-
Arghhhh! Just wanted to start there.
I’ve got a simple javascript that works fine in a stand alone html file but mocks me when placed in a WP page.
I enqued the script in functions.php
wp_enqueue_script('guts-faq-collapse', get_template_directory_uri() . '/js/collapse.js', array(), 20141005, true);Are there limitations for JS in WP? If so, where can I read up on what to expect and how to overcome what should be simple issues? I would really appreciate any help. I put html below that shows the effect I’m trying to make happen.
<html> <head> <script language="JavaScript" type="text/javascript"> if (document.getElementById) { document.writeln('<style type="text/css"><!--') document.writeln('.texter {display:none} @media print {.texter {display:block;}}') document.writeln('//--></style>') } function openClose(theID) { if (document.getElementById(theID).style.display == "block") { document.getElementById(theID).style.display = "none" } else { document.getElementById(theID).style.display = "block" } } // --> </script> </head> <body > <span > <div onclick="openClose('a1')" style="cursor: pointer;"> <span style="color: #708B28;">The Content Title</span><br> </div> <div id="a1" class="texter"> This is the content that shows when you click the title.<br> </div> </span> </body> </html>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Getting javascript to work…’ is closed to new replies.