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