[Javascript] Get file extension from file path
2020-03-05 15:28:19
function fileExt(file) { var extension = file.substr( (file.lastIndexOf('.') +1) ); switch(extension) { case 'jpeg': case 'jpg': ...2020-03-05 15:28:19
function fileExt(file) { var extension = file.substr( (file.lastIndexOf('.') +1) ); switch(extension) { case 'jpeg': case 'jpg': ...2020-03-05 15:24:15
function validEmail( email ) { var emailArr = email.split(","); var ret = false; for(var i=0; i<emailArr.length;i++) ...2020-03-05 15:21:44
function formatBytes(bytes, decimals = 2) { if (bytes === 0) return '0 Bytes'; const k = 1024; const dm = decimals < 0 ? 0 : decimals; const ...2020-03-05 15:14:06
$('.modal-second').on('hidden.bs.modal', function () { if( ($('.modal-first').data('bs.modal') || {})._isShown ) { $('.modal-first').css('z-index','1050'); ...2019-10-08 16:04:08
Example for Video spliting function by interval (time range) Looping to images (.jpg) in folder ex <ul style="list-style: none" id="thumb-list"> <?php foreach(glob('ex/'.$h.'*.jpg') ...2018-10-09 12:11:13
$('iframe').load(function() { this.style.height = this.contentWindow.document.body.offsetHeight + 'px'; }); Ref: https://stackoverflow.com/questions/3846132/jquery-get-height-of-iframe-content-when-loaded ...2018-06-12 23:52:23
$('input[name=test]').keyup(function(){ this.value = this.value.toUpperCase(); }); ...2018-03-06 18:33:21
$('input[name=xxx]').keyup(function() { var $th = $(this); $th.val( $th.val().replace(/[^a-zA-Z0-9]/g, function(str) { alert('กรุณากรอกข้อมูลเป็นภาษาอังกฤษและตัวเลขเท่านั้น'); ...2016-11-23 11:46:51
This is the jquery code for disabling form submit by press Enter button. But it allowed to key press Shift+Enter for insert new line to textarea <script> $(function() { // DOM ready ...2016-11-01 12:00:40
หลายคนคงจะเคยเห็นกันอยู่บ่อยๆ นะครับ เวลาที่เข้าไปยังเว็บไซต์ใดเว็บนึ่ง แล้วมี Popup เด้งขึ้นมาแสดงที่หน้า Home page ก่อนจะเข้าไปชมเว็บไซต์ ประโยชน์ของ popup ลักษณะนี้ คือสามารถโปรโมต โฆษณา ประชาสัมพันธ์ข้อมูลข่าวสารต่างๆ เพื่อนำเสนอข้อมูลแก่ ...2016-09-17 11:54:12
Script นี้เป็น framework ที่ผมสร้างขึ้นมา ทำงานบน Form ที่ให้ User กรอกรายละเอียดจังหวัด อำเภอ ตำบล และรหัสไปรษณีย์ ซึ่งมีการทำงานแบบ Dropdown List เลือกข้อมูลแบบลำดับขั้น โดยเลือกจากจังหวัดก่อน จากนั้น javascript ที่ทำงานแบบ Ajax จะไป Run คำสั่งในไฟล์ ...2016-09-09 12:29:10
datepicker เป็นสคริปท์ที่ถูกใช้งานค่อนข้างบ่อยครั้ง สำหรับผู้ที่ต้องเขียน form input วัน/เดือน/ปี และส่วนตัวผมก็ใช้แทบทุกเว็บไซต์ที่มี back office เมื่อเวลาจะใช้ที ก็หลงๆลืมๆ ว่าจะใช้ไฟล์ไหนหรือฟังก์ชั่นอะไรบ้าง ผมเลยถือโอกาสนี้ นำมันมารวบรวมไว้บนเว็บฯ ...2016-09-08 11:07:33
How to call the function on parent window with javascript ? Main page <html> <head> <script> function openNew(){ popup_path = 'popup.html; ...2016-09-06 17:10:10
เป็นฟังชั่นในการตัด html tag ออกจาก text เพื่อการใช้งานข้อมูลแบบ plain text function strip(html) { var tmp = document.createElement("DIV"); tmp.innerHTML = html; return ...2016-09-06 12:09:07
Uncaught TypeError: window.showModalDialog is not a function เป็นเพราะ Chrome ในเวอชั่นใหม่ๆ ได้เลิก support function นี้ ดังนั้น เราจึงต้องปรับเปลี่ยนวิธีการเปิด popup ใหม่ showModalDialog มีข้อดีคือ มันสามารถส่งตัวแปรไปรับค่าจาก popup แล้ว ...2016-01-01 00:00:01
Jquery enable select option box (disabled attribute) Not work $('select[test]').attr('disabled',''); Work $('select[test]').prop('disabled',false); ...2013-03-11 15:13:51
javascript แบบ inline สำหรับการใช้งาน เปลี่ยน address ไปยังหน้าเพจที่ต้องการ ด้วยการใช้ select box และ onchange event ตัวอย่าง <select onchange='document.location.href=this.options[this.selectedIndex].value;'> <option ...2013-02-28 12:11:46
ปัญหานี้เกิดขึ้นจากการวางคำสั่งไว้ใน $().ready(function() { ... } ซึ่งจะสามารถทำงานได้ครั้งเดียวที่โหลดเพจขึ้นมา แต่ถ้ามีการเขียน เปลี่ยนแก้ไข html แบบ dynamic โดยใช้ innerText innerHtml , ajax หรือพวก open popup แล้วจะกลับมาทำงานในหน้า window.opener ซึ่งบางงาน ...