Home > Web Front-end > HTML Tutorial > The focus of textarea cannot be obtained under IE_html/css_WEB-ITnose

The focus of textarea cannot be obtained under IE_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:50:49
Original
1333 people have browsed it

<html lang="en"><head>	<meta charset="UTF-8">	<title>Document</title></head><body>	<textarea name="" id="" cols="30" rows="10" readOnly=true></textarea>	<script src="jquery-1.9.1.js"></script>	<script type="text/javascript">			$(function(){ 				$('textarea').on('click',function(){ 						$(this).attr('readOnly',false);						this.focus();				 })			});	</script></body></html>
Copy after login


Dear experts, the effect I want here is to be able to get focus after clicking the textarea and input directly. This code can be used under ff and chrome, but it must be used under ie. Click twice
How should I solve it? Sincerely help


Reply to the discussion (solution)

If input is allowed, use css to simulate the readOnly style , remove this css when focusing

If input is allowed, use css to simulate the readOnly style, remove this css when focusing

Brother, you don’t understand what I mean

This is already Solved what I saw on stackoverflow: Method 1 It’s not good to use select() to interact with it separately
Method 2 $ (this).attr('contentEditable',true) is handled in this way, but Google and Firefox Not supported, just handle it separately. This should be the best solution
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template