You're right, you just need to use the visible binding, which will only show the HTML element if the value of the observed is NOT null, undefined, or an empty string. This should work:
<div class="errorData" data-bind="visible: errorMsg, text:errorMsg"/> <div class="displayData" data-bind="visible: dataDisplay, text:dataDisplay" />
Also, if "dataDisplay" is really an array, you should use:
<div class="displayData" data-bind="visible: dataDisplay().length, text:dataDisplay" />
source share