jquery.function.js

/* --------------------------- 【CSS、HTMLの操作】 class属性付与 .addClass 要素前 before 要素後 after // jQuery("#wrap").after("<div id=\"bg-light\"></div>"); 最後 li:last-child 削除 .remove // jQuery("p.twCont [href*='jugem']").remove(); // jQuery("#rentalInfo .fr img").remove(); 属性の追加 jQuery('.cbox img').parents("a").attr({rel:"cbox1"});// 要素をさかのぼってaにrelを付ける 要素内の先頭へHTML生成 jQuery("#main h4.t4").prepend("<span class=\"t4Dot\"></span>"); 出力:<h4 class="t4"><span class="t4Dot"></span>XXXXXXXXX</h4> 要素の子要素をHTMLで包む jQuery("#main h4.t4").wrapInner("<span class=\"t4Dot\"></span>"); 出力:<h4 class="t4"><span class="t4Dot">XXXXXXXXX</span></h4> --------------------------- */ /* --------------------------- フェードイン -------------------------- */ // $(document).ready(function() { // setTimeout(function(){ // wrap.transitionAnimate({"opacity":"1"},"1000ms","ease-out"); // },800); // }); /* --------------------------- Retina-Srcset.js --------------------------- */ $(function(){ var retinaCheck = window.devicePixelRatio; if(retinaCheck >= 2) { // Retinaディスプレイのときを分岐させている $('img.retina').each( function() { var retinaimg = $(this).attr('src').replace(/\.(?=(?:png|jpg|jpeg)$)/i, '@2x.'); $(this).attr('srcset', retinaimg + " 2x"); }); } }); /* --------------------------- スマートフォンのみtelリンク有効 --------------------------- */ /* HTML <p>TEL<span class="tel-link">06-6372-1168</span></p> */ $(function(){ var ua = navigator.userAgent; if(ua.indexOf('iPhone') > 0 || ua.indexOf('Android') > 0){ $('.tel-link').each(function(){ var str = $(this).text(); $(this).html($('<a>').attr('href', 'tel:' + str.replace(/-/g, '')).append(str + '</a>')); }); } }); /* --------------------------- <html>タグにブラウザ別class名を付与 --------------------------- */ var ua, verArr, version, ieVer, ie, chrome, firefox, opera, safari; ua = navigator.userAgent; // IEかそれ以外かどうかを判定 if (ua.match(/msie/i) || ua.match(/trident/i)) { // IEの場合はバージョンを判定 verArr = /(msie|rv:?)\s?([\d\.]+)/i.exec(ua); version = (verArr) ? verArr[2] : ''; version = version.replace('.', '_'); ieVer = "ie"+version; // "ie11_0"等を付与 $("html").addClass(ieVer); } else { if (ua.match(/chrome/i)) { // chrome $("html").addClass('chrome'); } else if(ua.match(/firefox/i)) { // firefox $("html").addClass('firefox'); } else if(ua.match(/opera/i)) { // opera $("html").addClass('opera'); } else if(ua.match(/safari/i)) { // safari $("html").addClass('safari'); } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.