跳到主要內容

發表文章

目前顯示的是 2015的文章

使用滑鼠拖曳列表中的元素做重新排序-jQuery UI Sortable Widget

<style type="text/css"> ul,li{list-style-type:none;} ul.items li{border:1px solid #ccc;padding:5px 0;background-color:#ccc;color:#000;padding:2px;margin:1px 0;} ul.items li.placeholder {position:relative;} ul.items li.placeholder:before {position: absolute;} ul.items li:hover{cursor:move;} .deptList{margin:0 auto;width:200px;height:400px;} .deptList ul.items{width:200px;height:400px;overflow:auto;border:1px solid #ccc;padding:0;} </style> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> <script type="text/javascript"> $(function () { var group = $("ul.items").sortable({ update: function (event, ui) { var data = ''; $("ul.items li").each(function (i, el) { var p = $(el).attr('data-id'); data += ',' +p; }); if (...

在contenteditable裡的固定位置插入html

<div id="test" contenteditable="true">Some editable text</div> < input type="button" unselectable="on" onclick="displayTextInserter();" value="Insert text"> <div id="textInserter"> <input type="text" id="textToInsert"> <input type="button" onclick="insertText()" value="Insert"> </div> <script type="text/javascript"> function saveSelection() { if (window.getSelection) { sel = window.getSelection(); if (sel.getRangeAt && sel.rangeCount) { return sel.getRangeAt(0); } } else if (document.selection && document.selection.createRange) { return document.selection.createRange(); } return null; } function restoreSelection(range) { if (range) { if (window.getSelection) { sel = window.getSelection(); ...

存取iframe元素

$(function () { $('#_iframe').load(function () { var $iframe = $(this), $contents = $iframe.contents(); // 取得 iframe 中的元素 var t1 = $contents.find('#t1').val(); // 取得 radio checked value var checkedVal = $contents.find("[name='uploadType']:checked").val(); // 設定 iframe 中的元素 $contents.find('#t2').val('我的值是由外部指定的!!'); $contents.find('#t2').css('color', 'red'); // 控制 iframe 中的按鈕觸發事件 $contents.find('#sbtn1').click(); // 執行 iframe 中定義的方法 $iframe.get(0).contentWindow.iframeMethod(); // 執行各種動作時可以再判斷 $contents 是否為 null }); });

Jquery lazyload with ajax

<img class="lazy" data-original="real.jpg" src="gray.jpg"> $("img.lazy").lazyload({ effect: "fadeIn" }).removeClass("lazy"); $(document).ajaxStop(function(){   $("img.lazy").lazyload({ effect: "fadeIn" }).removeClass("lazy"); }); or $(document).on('DOMNodeInserted', 'img.lazy', function() {   $(this).lazyload({     effect: 'fadeIn'   }); });

t-sql: 去除html tag

CREATE FUNCTION [dbo].[fn_stripHtml] (@htmlText VARCHAR(MAX)) RETURNS VARCHAR(MAX) AS BEGIN     DECLARE @Start INT     DECLARE @End INT     DECLARE @Length INT     SET @Start = CHARINDEX('<',@htmlText)     SET @End = CHARINDEX('>',@htmlText,CHARINDEX('<',@htmlText))     SET @Length = (@End - @Start) + 1     WHILE @Start > 0 AND @End > 0 AND @Length > 0     BEGIN         SET @htmlText = STUFF(@htmlText,@Start,@Length,'')         SET @Start = CHARINDEX('<',@htmlText)         SET @End = CHARINDEX('>',@htmlText,CHARINDEX('<',@htmlText))         SET @Length = (@End - @Start) + 1     END     RETURN LTRIM(RTRIM(@htmlText)) END GO

How to install iCloud on Windows Server

現象: iCloud 無法運行或發生錯誤 原因: 新版的 iCloud 只能在 Windows 7 或 8 運行 修改步驟: 1. 安裝  7-zip ,如果你還沒有安裝 2. 安裝 Orca , 這是 Microsoft 提供的 MSI 編輯器 3. 下載   iCloud control panel installer ,如果你還沒有下載 4. 用 7-zip 解壓縮  iCloudSetup.exe 5. 開啟 Orca,開啟 iCloud64.msi,假設你系統是64bit 6. 找到 LaunchCondition table 7. 將 LaunchCondition table 刪除 8. 存檔,關閉 Orca 9. iCloud64.msi 按右鍵,點安裝

Firefox介面不隨解析度縮放

1. 網址列輸入:About:config 2. 搜尋:layout.css.devPixelsPerPx 3. 如果要讓Firefox介面隨系統解析度自動縮放,則使用預設值 -1;若想使用Firefox 21之前的設定,請輸入1.0,表示介面不隨解析度縮放。若要縮小則使用小於1.0的數值,最小為0.05。若要放大則使用大於1.0的數值。

Add a Facebook App to Page Tab and Get the Selected Page Id then Redirect to the Page

FB.ui( { method: 'pagetab' }, function (response) { if (response != null && response.tabs_added != null) { $.each(response.tabs_added, function (pageid) { FB.api(pageid, function (response) { console.log('selected page id is '+pageid+', the page url is ' + response.link); }); }); } } );