jQuery การหา parent การใช้ Debug

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: jQuery การหา parent การใช้ Debug

jQuery การหา parent การใช้ Debug

โดย M009 » 02/07/2013 7:09 pm

การหา parent() นั้นจะ alert ออกมา เป็น Object
วิธีการหาค่าของมันนั้น จะต้องใช้ คำสั่งเข้ามาช่วย

ตัวอย่าง

โค้ด: เลือกทั้งหมด

<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
   jQuery(document).ready(function(){
          var testp = jQuery("#testp").parent();
		  console.log(testp);
		  alert(testp);
  });

</script>
<table>
   <tr>
          <td id='testp'>1234</td>
   </tr>
</table>
debug.jpg
debug.jpg (25.28 KiB) Viewed 868 times
เมื่อรับดูแล้วเปิด debug >> console ก็จะเห็น parent()ของเรา

ข้างบน