Display attribute ‘Title’ of element/s in other element on Focus or Click

one of the possible solutions JSFiddle:

$(document).on('mouseenter', 'input,select', function (e) {
    $('#current-control-label').text($(this).data().title);
});

$(document).on('mouseleave', 'input,select', function (e) {
    $('#current-control-label').text(' ');
});

html:

<table>
<tr>
    <td><input type="text" data-title="Name" /></td>
    <td>
        <select data-title="Gender">
            <option value="M">Male</option>
            <option value="M">Female</option>
        </select>
    </td>
    <td><input type="radio" data-title="Active" /></td>
</tr>
<tr>
    <td colspan="2">
        <span id="current-control-label">&nbsp;</span>
    </td>
</tr>
</table>

Leave a Comment