The following snippets do the following in your forms:
- Where an instruction is given => inserts a question mark image after the label
- on hover the question mark display the field instruction as a tooltip.
$(document).on('knack-scene-render.any', function(event,page) { $('.kn-input').each( function () { var tttx = $(this).find('p').text(); if (tttx ==="") {} else { $(this).find('.kn-input-label').css('position','relative'); $(this).find('label > span.kn-input-label').append('<span class="ttpict"><img class="ttpict" style="padding-left:3px ; margin-bottom: -3px" src="/*your image url here*/"</img></span>'); $(this).find('.ttpict').attr('data-tooltip', tttx); $(this).find('p').css('display', 'none'); } }); });
/* Hide the tooltip content by default */ [data-tooltip]:before, [data-tooltip]:after { visibility: hidden; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter: progid: DXImageTransform.Microsoft.Alpha(Opacity=0); opacity: 0; pointer-events: none; }/* Position tooltip above the element */
[data-tooltip]:before {
position: absolute;
bottom: 110%;
left: 50px;
margin-bottom: 5px;
margin-left: -50px;
padding: 7px;
width: 225px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
/background-color: #000;/
background-color: rgba(106,168,79,1);
color: #fff;
content: attr(data-tooltip);
text-align: left;
font-size: 14px;
font-weight: normal;
line-height: 1.2;
z-index:99999;
}/* Triangle hack to make tooltip look like a speech bubble */
[data-tooltip]:after {
position: absolute;
bottom: 110%;
left: 20px;
margin-left: -5px;
width: 0;
border-top: 5px solid #000;
border-top: 5px solid rgba(106,168,79,1);
border-right: 5px solid transparent;
border-left: 5px solid transparent;
content: " ";
font-size: 0;
line-height: 0;
z-index:99999;
}/* Show tooltip content on hover */
[data-tooltip]:hover:before,
[data-tooltip]:hover:after, [data-tooltip]:focus:before, [data-tooltip]:focus:after {
visibility: visible;
-ms-filter: “progid:DXImageTransform.Microsoft.Alpha(Opacity=100)”;
filter: progid: DXImageTransform.Microsoft.Alpha(Opacity=100);
opacity: 1;
}
demo here