I have the following code:
<div id="DivPassword" title="test" >
I want to change the div title and I have the following code:
function ChangeAttribute() {
$("#DivPassword")
.attr('title', 'Photo by Kelly Clark');
$('#DivPassword').dialog('open');
return false;
}
When the dialog is opened, the title is still test! if I don't assign any title to the div, the dialog doesn't show any title. How can I correct that?
function ChangeAttribute() {
$("#DivPassword")
.attr('title', 'Photo by Kelly Clark')
.dialog('open');
alert($("#DivPassword").attr('title'));
}
$('#DivPassword').dialog({
autoOpen: false,
width: 800,
buttons: {
"Cancel": function() {
$(this).dialog("close");
},
"Accept": function() {
alert($(this).attr('title'));
$(this).dialog("close");
}
}
});
<script type="text/javascript">
var Dtitle;
$(function() {
$('#DivPassword').dialog({
autoOpen: false,
width: 800,
title : Dtitle,
buttons: {
"Cancel": function() {
$(this).dialog("close");
},
"Accept": function() {
$(this).dialog("close");
}
}
});
});
function ChangeAttribute(name) {
$("#DivPassword")
.attr('title', name)
.dialog('open');
Dtitle = $("#DivPassword").attr('title');
alert(Dtitle);
}
</script>
To set the title property on an element, use: $('#yourElementId'). prop('title', 'your new title');
Drag the calculated field to the appropriate tooltip and you'll see an ATTR dimension pill with a tooltip logo in the Marks card. Insert the ATTR budget and adjusted inflated gross calculated fields into its corresponding tooltip as seen in Image 6. After that, you're dynamic tooltip should work!
You can change the title of a dialog directly with:
$('#DivPassword').dialog('option', 'title', 'Photo by Kelly Clark');
This will work in your case. In fact, your code to change the title attribute is correct. I guess that the dialog plugin creates the dialog when .dialog is called first. The open method just displays the dialog then, without re-creating it from the div.
You can change ANY attribute from any DOM element with jQuery as easy as:
$("#divMessage").attr('title', 'Type here the new Title text');
Cheers!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With