Child element not to inherit parent property (not style) in html

144 views Asked by At
<div id='outer_div' onselectstart='return false;'>
     <textarea id='txtbx'></textarea>
</div>

In the above code, txtbx, will not allow the user to select its content as it is inheriting the property onselectstart from it's parent div outer_div. Whereas I donot want txtbx to inherit onselectstart from it's parent div. How to achieve this in javascript.

I have written a javascript code, that internally makes text selection from the textarea. Hence I cannot just write onselectstart ='return true;' as I have something else to happen in this case. I tried the below methods, but none worked

Trial 1:

<div id='outer_div' onselectstart='return false;'>
     <textarea id='txtbx' onselectstart=''></textarea>
</div>

Trial 2:

<div id='outer_div' onselectstart='return false;'>
     <textarea id='txtbx' onselectstart='default'></textarea>
</div>

Trial 3:

<div id='outer_div' onselectstart='return false;'>
     <textarea id='txtbx'></textarea>
</div>
delete document.getElementById('txtbx').onselectstart

NOTE: This support is required as this code has to run in IE8

0

There are 0 answers