I’m new to JQuery and have a script that creates a dialog via Ajax using the HREF and TITLE tags of an link. The problem is, I can easily pull the HREF tag out of “this”, but the same doesn’t apply at all to the TITLE tag. In the following example, why does an alert correctly appear with the HREF, but not with the TITLE?
<script>
$(function (){
$('a.ajax').click(function() {
var href = this.href;
alert(href);
var title = this.title;
alert(title);
return false;
});
});
</script>
<a class="ajax" title="A nice title" href="test.html">Click me!</a>
I konw I’m missing something small… I’ve already tried “var title = $(this).title;” and “var title = $(this).attr(‘title’);” and other similar variations, but none get the title.
this.titleis perfectly valid.Also your code is working fine.
Check it here : JSFiddle Working Example