I have the following code :
HTML:
<input type='text' class='a' /> <div class='inst' tag='a'></div> <input type='text' class='b' /> <div class='inst' tag='b'></div> <input type='text' class='c' /> <div class='inst' tag='c'></div>
JS:
$(function() { $('.inst').click(function() { alert($(this).attr('tag') + ' clicked'); }); $('[type=text]').focus(function() { show_inst($(this).attr('class')); }).blur(function() {
CSS
.inst { width: 200px; height: 100px; border: 1px solid black; margin: 10px; cursor: pointer; }
It works fine: when I press inst I see a warning message, and when the input becomes focused, an instruction appears.
Now I want the inappropriate instruction to disappear on blurring. So I tried adding a commented line inside blur() . This does not work like that because blur() is called first and deletes the instruction, so if I click on the instruction nothing happens.
How can i solve this?
javascript html click onblur
Misha moroshko
source share