My code snippet is creating a div with specific classes and elements:
'<div class="ctrl-info-panel col-md-12 col-centered">'+
'<h2>You do not have any projects created at the moment.</h2>'+
'<div id="t1" style="display:inline-flex" data-toggle="tooltip">'+
'<p><a href="create_project.jag" class="cu-level2-btn btn-add-new-dark ' + appendCreateprojectDisabled(noOfDatasets) + '" data-toggle="tooltip" data-original-title="Create Project"><span>Create Project</span></a></p>'+
'</div>'+
'</div>'
In my attempt to modify an attribute within #t1
, I wrote the following function:
function appendCreateprojectDisabled(noOfDatasets) {
var classAppend = '';
if(noOfDatasets == 0) {
$("#t1").attr('title','No datasets available');
classAppend = 'cu-level-btn-disabled';
}
return classAppend;
}
However, despite providing a value for noOfDatasets
as 0, the expected attribute is not being added. The tooltip text does not show up as intended. What could be causing this issue?
It is important to note that the value of noOfDatasets
is set to 0.