jQuery can't get the value in textarea through val()

1  Xiaobian defines a textarea control, but cannot get the textarea object and assign it according to the id.
2  
3  After experimentation, the reason was found. The code is as follows:
 4  
5  <! DOCTYPE html > 
6  < html > 
7  < head > 
8  < script src ="/jquery/jquery-1.11.1.min.js" > 
9  </ script > 
10  < script > 
11  
12  $ (document).ready( function (){
 13    $( " #t1 " ).val( " Assignment succeeded " );
 14 
15   $("#t2").val("赋值成功");
16 });
17 </script>
18 </head>
19 <body>
20 
21 <textarea id="t1" rows="5" cols="100"   class="propel"></textarea>
22 
23 <textarea rows="5" cols="100"  id="t2" class="propel"></ textarea > 
24  </ body > 
25  </ html > 
26  
27  
28  
29                   The reason why the textarea control with the id "t2" cannot obtain the textarea according to the ID is because the id is written together with the class when it is defined. If the id is written in front of rows or cols, or after the class, the textare control can be obtained through the ID.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325067007&siteId=291194637