• Wolfenstein

    (@wolfenstein)


    Well right now I have brain lock and this should be simple.
    Basically I want to add a onclick event to the content in this function in which it applies a css class.

    function my_onclick_handler($atts, $content = null)
    {
    return “<div onclick= class=’my css’ >”.do_shortcode($content).”</div>”;
    }

    Thanks in advance.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Set the onclick attribute to call a javascript function, also output a <script> block that declares that function, so something like this (untested):
    return "<div id='target' onclick='setCSS();' class='my css' >".do_shortcode($content)."</div><script>function setCSS(){document.getElementById('target').className='newClass';}</script>"

Viewing 1 replies (of 1 total)

The topic ‘Need help with onclick with shortcode’ is closed to new replies.