Ctrl+enter Submit Message

Source: Internet
Author: User

Tag: false element Test row Jquer har boolean value on ()

<! DOCTYPE html>
<meta charset= "UTF-8" >
<title>ctrl+enter Submit Message </title>
<style>
</style>
<script src= "Jquery-1.9.1.js" ></script>
<script>
/*$ (document). KeyDown (function (EV) {
alert (Ev.which); Test result Enter key value is 13
});*/

$ (function () {
$ ("#btn"). Click (function (EV) {
var con=$ ("#txt2"). Val () + "\ n";//Line break \ n
var aa=$ ("#txt1"). html ();
$ ("#txt1"). HTML (Aa+con);
$ ("#txt2"). Val ("");

});
$ ("#txt2"). KeyDown (function (EV) {//input focus is on the text box, so add an event to it
if (Ev.which==13&&ev.ctrlkey) {//ctrlkey is a Boolean value that is true when CTRL is pressed, false;shift/alt when not pressed, and so on.
var con=$ ("#txt2"). Val () + "\ n";
var aa=$ ("#txt1"). Val ();
$ ("#txt1"). Val (Aa+con);
$ ("#txt2"). Val ("");
}
});
});
</script>
<body>
<textarea id= "Txt1" cols= "rows=" ></textarea><br>
<input type= "text" id= "txt2" style= "width:300px" >
<button id= "BTN" > Submit </button>
</body>
Add: First, value
Value: $ ("#Text1"). Val ();
Set: $ ("#Text1"). Val ("Bus");
Empty: $ ("#Text1"). Val (""); Empty

Second, HTML
Get: $ ("Test"). HTML ();(if it's a set of elements, take the first one)
Set: $ ("Test"). HTML ("content");(if it is a set of elements, it will be assigned to all elements)
Empty: $ ("Test"). empty ();

Third, the text box to get focus
$ ("#Text1"). Focus ()

Ctrl+enter Submit Message

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.