Domanda

I use a click event in jQuery in my windows sidebar project that doesn't work in the sidebar (i don't think it's binded), but it works on a browser (even IE7). Here is a simple example from my project that doesn't work in my sidebar, and I hope somebody can tell me why, because I couldn't figure it out.

<html>
    <head>

        <script type="text/javascript" src="jquery-1.7.1.js"></script>
        <script type="text/javascript">
            $(function(){
                $('#clickable_div').click(function(){
                    $('#textContent').append($('<h4 />').text('change'));
                });
            });
        </script>
    </head>
    <body style="width: 200px; height: 250px; border: 1px solid black;">
        <div id="clickable_div" style="width: 50px; height: 50px;border:1px solid black;">Click the div</div>
        <div id="textContent"></div>
    </body>
</html>
È stato utile?

Soluzione

I found a solution for my problem, even if I don't know why it does not work with jQuery's click method.

I used javascript's onclick, and it's working now.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top