Can I execute javascript on an element that is inside ui.selectable element?
As the title says: can I execute javascript onclick on an dom element that is inside jQuery's ui.selectable dom element.
I hope it's clear where the problem is. The div inside my selectable div cannot be clicked because it inherits its parent elements selectable property.
I tried sth like this:
<script type="text/javascript">
$("#myInnerDiv").click(function(event){
event.stopPropagation();
/*event.stopImmediatePropagation();*/
alert("drek");
});
</script>
<div id="selectable">
<div id="myInnerDiv">
<!-- here is where I am clicking and Alert is Not showing up -->
</div>
</div>
It doesn't work. I'm 开发者_运维知识库stuck here for three days now and would greatly appreciate any suggestions!
You need to wrap your javascript in a $(function() {}); call:
$(function() {
$("#myInnerDiv").click(function (event) {
event.stopPropagation();
/*event.stopImmediatePropagation();*/
alert("drek");
});
});
or you can put the script block after the HTML.
精彩评论