This example works well and the same I use on my project, but the data I use, in this case the div with the data-name
attr is loaded by ajax and it looks like it doesn't work.
In the console, firefox output this after the click
:
getPreventDefault() sollte nicht mehr verwendet werden. Verwenden Sie stattdessen defaultPrevented.jquery.min...
js
$(document).ready(function() {
$("#content div").click(function() {
var title = $(this).data("name");
$("#content div").text(title);
});
});
html
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div id="content">
<div data-name="Neu"></div>
</div>
css
#content {
width: 100%;
height: 100%;
}
#content div {
width: 50px;
height: 50px;
background: red;
color: white;
}
Delegated event handler :
$(document).ready(function() {
$(document).on('click', '#content div', function() {
var title = $(this).data("name");
$("#content div").text(title);
});
});