我有以下代码:
<div id="DivPassword" title="test" >
function ChangeAttribute() { $("#DivPassword") .attr('title','Photo by Kelly Clark'); $('#DivPassword').dialog('open'); return false; }
当对话框打开时,标题仍然是测试!如果我没有为div分配任何标题,该对话框不会显示任何标题.我该怎么纠正?
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,title : Dtitle,"Accept": function() { $(this).dialog("close"); } } }); }); function ChangeAttribute(name) { $("#DivPassword") .attr('title',name) .dialog('open'); Dtitle = $("#DivPassword").attr('title'); alert(Dtitle); } </script>