<!DOCTYPE html> <html> <head> </head> <body style="font:14px/1.5 'Odor Mean Chey'">If you click on the "Hide" button, I will disappear.
<script> $("#hide").click(function(){ $("p").hide(); }); $("#show").click(function(){ $("p").show(); }); </script> </body> </html>
If you click on the "Hide" button, I will disappear.
ជាទូទៅ ទំរង់នៃវិធីឈ្មោះ hide() និង show() គឺដូចខាងក្រោមនេះ៖
$(selector).hide(speed,callback); $(selector).show(speed,callback);ដូចនេះយើងអាចផ្តល់ដំណឹងមិនចាំបាច់ចំនួនពីរអោយទៅវិធីទាំង ២ ខាងលើនេះ។ ដំណឹងមិនចាំបាច់ speed គឺជាកត្តាតំរូវអោយធាតុ HTML បាត់ខ្លួនបន្តិចម្តងៗ អាស្រ័យទៅតាមដំណឹងដែលជា speed នេះ ដែលអាចជាពាក្យថា «slow» ឬ «fast» ឬជាចំនួនលេខ millisecond ។
ចំណែកឯដំណឹងមិនចាំបាច់ដែលជា callback វិញអាចត្រូផ្តល់អោយទៅវិធីទាំងពីរខាងលើនេះ ក្នុងគោលបំណងតំរូវអោយក្បួនឬវិធី callback ត្រូវយកទៅប្រើ នៅពេលដែលបញ្ជាទាំងឡាយត្រូវអនុវត្តបានចប់សព្វគ្រប់។ ពិនិត្យកម្មវិធីខាងក្រោមនេះ៖
<!DOCTYPE html> <html> <head> </head> <body style="font:14px/1.5 'Odor Mean Chey'">This is a paragraph with little content.
This is another small paragraph.
<script> $("button").click(function(){ $("p").hide(1000); }); </script> </body> </html>
This is a paragraph with little content.
This is another small paragraph.
ចំពោះវិធីឈ្មោះ toggle() វិញ អាចត្រូវយកទៅប្រើប្រាស់សំរាប់ចុចឆ្លាស់គ្នាដើម្បីបំបាត់ឬបង្ហាញធាតុ HTML ដូចខាងក្រោមនេះ៖
<!DOCTYPE html> <html> <head> </head> <body style="font:14px/1.5 'Odor Mean Chey'">This is a paragraph with little content.
This is another small paragraph.
<script> $("button").click(function(){ $("p").toggle(); }); </script> </body> </html>
This is a paragraph with little content.
This is another small paragraph.
ទំរង់ទូទៅនៃវិធីឈ្មោះ toggle() គឺដូចខាងក្រោមនេះ៖
$(selector).toggle(speed,callback);