To make text unselectable one needs to understand that there are two methods. If we need Opera and Internet Explorer prior to version 10 (which is in most of the cases positive)) ) - we need to use the unselectable attribute with the value of on.
What is important to notice here that if we set this attribute to the parent wrapper - .Non-Select in this case - the child-elements' text can still be selected - open this fiddle in opera or IE up to 9 to check. So we need to add this attribute to every single element that should not be selected (possibly dynamically via javascript if there are many (or unknown number) of possible child elements).
To disable other browsers' selection we may use the css3 user-select property. A cool way of adding this css will be via attribute selector like so:
[unselectable="on"]{
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none
}
Thus - the text on any element with this attribute cannot be selected in most of the popular browsers.
The second way is shorter. If we don't need IE or Opera - your code must undergo a small change for it to work in Firefox, Chrome and IE10.
.Non-Select {
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: -moz-none;
-ms-user-select: none;
user-select: none;
}
.Non-Select input {
-webkit-user-select: text;
-khtml-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
user-select: text;
}
Pay attention to the non-standart -moz-none value I added. If we read carefully about this property on MDN we will see that Mozilla introduced this non-standart version to enable selection of child elements. A live example of the second method can be seen here: - http://jsfiddle.net/jxnEb/5/
Edit: There has been a similar question on selection. Pay attention to the accepted answer where the author wrote a function to add the unselectable attribute recursively to all the child-elements. (in your case - input should be filtered of course).