Error msg:
Error shows “Failed to get text for stylesheet (#): No style sheet with given id found”
Ans:
closed all the files in the 'source' tab.
.disable-collapse { .navbar-collapse.collapse { display: block!important; } .navbar-nav>li, .navbar-nav { float: left !important; } .navbar-nav.navbar-right:last-child { margin-right: -15px !important; } .navbar-right { float: right!important; } }
以往JavaScript和CSS都要透過id或是class和HTML產生關聯, 造成典型的問題就是一個CSS的style用不到了, 但是怕刪除class讓JS失效. 目前最新的解法是:JavaScript少class。 改用 HTML5 data- attributes 來當JS和HTML之間的橋梁 Twitter Bootstrap: css => class="nav nav-tabs" js =>
非由使用者的操作直接引發的開新視窗 瀏覽器會詢問,==================================
點按鈕後直接開新視窗會被視為是使用者的操作引發的,
但async true時會在另一個thread執行,就不會被當成是使用者的操作,
可以改成點擊後直接開新分頁,新分頁裡再用ajax讀資料,
或是先開新分頁,原分頁讀到資料後再傳給新分頁應該也行
jQuery(document).ready(function(){ jQuery('#foo').on('click', function(){ jQuery('#bar').simulateClick('click'); }); }); jQuery.fn.simulateClick = function() { return this.each(function() { if('createEvent' in document) { var doc = this.ownerDocument, evt = doc.createEvent('MouseEvents'); evt.initMouseEvent('click', true, true, doc.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null); this.dispatchEvent(evt); } else { this.click(); // IE Boss! } }); }
flow:web_A pass parameter to web_B method: use http get .in web_A 's js file var url = "url?"+window.abStoreUserToken+"="+data[0]['userToken']; window.location = url; .in web_B 's js file //handle url redirect var hashTagQuery = handleHashTagString(window.location.search); //get parameter from another web if(hashTagQuery['abStoreUserToken']!=null){ sessionStorage.setItem(window.abStoreUserToken, _toJSONString(hashTagQuery['abStoreUserToken'])); } //change url without reload, and clear ori url from history window.history.replaceState("object or string", "Title", "url without parameter" );
$(window).on('resize', function() { var win = $(this); //this = window console.log(win.height()); console.log(win.width()); });
$(window).on('hashchange', function(e) { console.log("hashchange"); $('#playAudioModal').modal('hide'); });
.nav-tabs > li.active > a, .nav-tabs > li.active > a:hover, .nav-tabs > li.active > a:focus { { border-color: #DDDDDD #DDDDDD transparent; }
$(document).on('hidden.bs.modal', '#your_modal_id', function() { console.log("you can do things here"); });Purpose:Do things when modal closed
//Just use the selectedIndex property of the DOM element: alert($("#dropDownMenuKategorie")[0].selectedIndex); //reason: // property. Adding [0] converts the jquery object to a javascript object which has the selectedIndex property. This example won't work without [0]
template += ' '; template += ''; template += ''; template += ' '; $template = $(template); for (i = 0; i < channelItemJson.length; i++) { var $newItemCol = $template.clone(); $newItemCol.find('img').attr('src', window.itemImgPreUrl + channelItemJson[i]['localCoverPath']); $newItemCol.find('p').text(channelItemJson[i]['name']); $newItemCol.find(".channel-item-detail").on("click", { elements: $newItemCol, }, handler2ItemDetail); //$('.search-all-price-group').show(); //this strategy will cause side-effect //beacuse there are many '.search-all-price-group' class //this is right $newItemCol.find('.search-all-price-group').show(); $("#scroll-container").append($newItemCol.fadeIn()); }'; template += ''; template += ''; template += '
'; template += ''; template += 'name
'; template += ' '; template += ' '; template += '
.html
.js .ybox { position: relative; width: 40px; height: 100px; background: rgba(255, 200, 0,1); z-index: 1; margin-top: 30px; pointer-events: none; //pointer-events: auto; } .ybox:hover{ background: rgba(0, 50, 100, .8); } .gbox { position: absolute; top: 0; left: 0; width: 200px; height: 50px; background: rgba(0, 220, 170, 1); z-index: 0; } .gbox:hover{ background: rgba(0, 50, 100, .8); }
.htmlthis is test I don't want #clickable to handle this click event.
.js $("#clickable a").click(function(e) { //do something e.stopPropagation(); }) $("#clickable").click(function(e) { //do something alert('clickable'); })here is link that you test
假設 navbar-brand 為用jquery load進來的html 此時下面寫法無法執行 $("a.navbar-brand").on("click", function() { //code here }); 解法一 不要用jquery load 進html, 解法二 Event Delegation ex: $(document).on("click", 'a.navbar-brand', function() { //code here }); ref:http://www.cnblogs.com/moonreplace/archive/2012/10/09/2717136.html