การอ่านค่าจาก id ของ tag html ด้วย jquery

ตอบกระทู้

รูปแสดงอารมณ์
: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] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: การอ่านค่าจาก id ของ tag html ด้วย jquery

การอ่านค่าจาก id ของ tag html ด้วย jquery

โดย mindphp » 30/08/2009 12:17 am

การอ่านค่าจาก id ของ tag html ด้วย jquery
เช่นมี tag p มี id= example_placeholder

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

<p id="example_placeholder">Existing content that will be replaced.</p>
อ่านค่าโดยใช้

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

$('#example_placeholder').html();
และถ้าจะกำหนดค่าให้ กับ id ของ tag ใช้

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

$('#example_placeholder').html('This existing content has been replaced with this content.');
เพิ่มค่าลงใน id

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

$('#example_placeholder').append(' This text has been appended to the end.');

ข้างบน