i’m trying to change the title attribute of a div when clicking on a link but it’s not working
here’s the code
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function(e) {
$("a#change").click(function() {
$("#city").attr("title", "new title");
});
});
</script>
and the body :
<a href="#" id="change">change</a>
<div id="city" title=""></div>
Working Fiddle
If you want to change any property of element, you can use
.attr()or.prop(). But here i used.attr().For More Examples See Documentation:
Documentation