I am doing a javascript script that work like bookmark. After allot of code i need to click in one of the divs I got but i can’t get it. If I put mouseover it works but no with click
I am using query
js:
var $j = jQuery.noConflict();
$j('<div></div>').prependTo($j(this)).attr('id', 'shadow').css({
'height': '220px',
'width': '220px',
'background-color': 'black',
'position': 'absolute',
'top': 0,
'left': 0,
'opacity': 0.4,
'cursor': 'pointer'
}).click(function() { //this dons't work i try to put apart
//But if I put bind('mouseover' it works
alert('a');
//...more stuff
});
In my HTML code its get like this:
<div id="div0" class="div" style="position: relative; ">
<div id="shadow" style="height: 220px; width: 220px; background-color: black; position: absolute; top: 0px; left: 0px; opacity: 0.4; cursor: pointer; "></div>
<img class="select" id="select0" src="url..." onclick="alert('aaa')">
<img src="url..." class="img" id="img0" height="62" width="220" style="margin-top:79px"></div>
</div>
I put an alert directly to the image and it doesn’t work neither
Thanks for all the help
Assuming that you’ve setup a shortcut for jQuery to be $j, I’ve created a sample jsFiddle:
http://jsfiddle.net/TxKPD/
Since it wasn’t clear what $(this) was in your query i simply appended your element to the body. Everything is working with the click handler. So that leaves the question, what is triggering your script and what is $(this) ?