How to use jquery select() method

青灯夜游
Release: 2022-03-01 17:18:07
Original
2732 people have browsed it

In jquery, the select() method is used to trigger a select event, or specify an event processing function to be run when a select event occurs; syntax "$(selector).select()" or "$(selector) .select(function)”.

How to use jquery select() method

The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.

The select event occurs when text in a textarea or input element of text type is selected.

select() method is used to trigger the select event, or specify the function to be run when the select event occurs.

Syntax:

  • Trigger the select event

$(selector).select()
Copy after login
  • Place the function Bind to select event

$(selector).select(function)
Copy after login

How to use jquery select() method

Example:

<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<script src="js/jquery-1.10.2.min.js"></script>
		<script type="text/javascript">
			$(document).ready(function() {
				$("input").select(function() {
					$("input").after(" Text marked!");
				});
			});
		</script>
	</head>
	<body>
		<input type="text" name="FirstName" value="Hello World" />
		<p>请试着选取输入域中的文本,看看会发生什么。</p>
	</body>
</html>
Copy after login

How to use jquery select() method

[Recommended learning: jQuery video tutorial, web front-end development video]

The above is the detailed content of How to use jquery select() method. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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