We have a simple textarea and a button.
<input type="button" id ="foo" disabled>
<textarea rows="12" name="message" id="message" cols="50"></textarea>
I need to:
- remove attribute disabled from button when some text in textarea selected
- set attribute disabled when selection canceled
First task was achieved with this code:$('textarea').select(function() {
$('#foo').attr('disabled','');});
But with the second task i havn’t any ideas.
Try to use below code
$(document).ready(function () {$('textarea').select(function() {$('#foo').attr('disabled',false)});
$('textarea').mousedown(function() { $('#foo').attr('disabled',true);});
});
Could you try using focus event?
Seems this event will be trigger once focusing on your DOM element.
answer was NO. you can use mouse down.