I am trying to call a DIV .click function, but it doesn't work. The div that I'm talking about is created with PHP.
This is the result from the PHP:
<div style="position:relative;width:700px;" id="colorcontainer">
<div class='color' style='background: url(kleuren/c121.jpg); background-size: 100 72; background-repeat:no-repeat;'><span class='txt'>CBM 121<br />Blank Gelakt Eiken</span></div>
</div>
Now I try to call the div .click function:
<script type="text/javascript">
$(document).ready(function(){
$('#colorcontainer > div').click(function() {
var name = this.css('background-image');
alert(name);
});
});
Now it does not show the alert at all. What am I doing wrong here? I've tried it without the document.ready, with .color and all sorts of stuff, but it just doesn't call the function.