An warware: duba idan an ɗora Jquery

Babban matsalar ita ce ba a loda jQuery ba lokacin da aka loda shafin.

if (typeof jQuery != 'undefined') {  
 // jQuery is loaded => print the version
 alert(jQuery.fn.jquery);
}

Layin farko yana bincika idan an ayyana m jQuery. Idan yana da, yana gudanar da lambar a cikin takalmin gyaran kafa. Layi na biyu yana buga faɗakarwa tare da sigar jQuery da aka ɗora.

Lambobin goma

Akwai ƴan hanyoyi don aiki tare da lambobi goma a jQuery. Hanya ɗaya ita ce yin amfani da aikin lamba(), wanda ke ɗaukar shigarwar integer kuma ya dawo da wakilcin ƙima na wannan lambar. Misali, don samun darajar 5.6, zaku iya amfani da aikin lamba () kamar haka:

lambar lamba = 5.6;

Wata hanyar yin aiki tare da lambobi goma a jQuery shine amfani da aikin parseFloat(). Wannan aikin yana ɗaukar shigarwa a cikin nau'i na kirtani kuma yana mayar da wakilcin-madaidaicin wannan lambar. Misali, idan kuna son samun ƙimar 5.6 azaman lamba mai iyo, zaku iya amfani da aikin parseFloat() kamar haka:

var num = parseFloat (5.6);

Math

Math a jQuery babban ɗakin karatu ne mai ƙarfi kuma mai sauƙin amfani don aiwatar da ayyukan lissafi akan abubuwan DOM. Ya haɗa da goyan baya don ƙididdigar asali, trigonometry, da algebra, da ƙarin abubuwan ci-gaba kamar ayyukan matrix da lissafin vector.

Math a cikin jQuery an gina shi a saman ɗakin karatu na gidauniyar jQuery, wanda ke ba da ƙaƙƙarfan tsarin daidaitawar mai binciken giciye. Sakamakon haka, Math a jQuery yana aiki tare da masu bincike na zamani guda biyu (ciki har da IE9 da kuma daga baya) da kuma tsofaffin masu binciken da ba sa tallafawa Library ɗin Gidauniya (kamar IE8).

Idan kana neman ƙara wasu ayyukan lissafi a aikace-aikacen yanar gizon ku, to Math in jQuery ya cancanci la'akari da shi.

Shafi posts:

Leave a Comment