返回列表 發帖

jQuery透過id取值賦值

  1. <script
  2.   src="https://code.jquery.com/jquery-3.5.1.js"
  3.   integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc="
  4.   crossorigin="anonymous"></script>
  5. <html>
  6. <div class='status' id='s1'>Nothing</div>
  7. <div class='status' id='s2'>Nothing</div>
  8. <div class='status' id='s3'>Nothing</div>
  9. </html>
  10. <script>
  11. alert($("#s2").html());
  12. </script>
複製代碼

作業:先取值,再加上一段字串,然後賦值!

TOP

  1. <script
  2.   src="https://code.jquery.com/jquery-3.5.1.js"
  3.   integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc="
  4.   crossorigin="anonymous">
  5. </script>
  6. <html>
  7.   <div id="status">Nothing</div>
  8. </html>
  9. <script type="text/javascript">
  10.   $("#status").html($("#status").html()+" happen.");
  11. </script>
複製代碼
https://www.facebook.com/DABRiXPERT6584

TOP

返回列表