【笔记】随笔记录
weui提示框
$.toast("驗證是否停機!",'text')
$.toast('請填寫正確賬號!', 'cancel');? ?
$.toast('手機綁定成功!', 'can');?
$.showLoading("數據加載中");
$.hideLoading();
uexWindow.toast("0", "5", "錯誤", "2000")? ? ?(這是Appcan的)
?
時間延遲
setTimeout(function() { },1000)
周期(以毫秒計)來調用函數:
setInterval() 方法可按照指定的周期(以毫秒計)來調用函數或計算表達式。
開始:var int=self.setInterval("clock()",50)
取消:<button onclick="int=window.clearInterval(int)">
獲取下拉框的選項值
現在有一id=test的下拉框,怎么拿到選中的那個值呢?
分別使用javascript原生的方法和jquery方法
<select id="test"? name="">???
? <option?? value="1">text1</option>???
? <option?? value="2">text2</option>???
?</select>
1:var options=$("#test option:selected");? //獲取選中的項
2:alert(options.val());?? //拿到選中項的值
3:alert(options.text());?? //拿到選中項的文本
?阻止冒泡
?event.stopPropagation();
Event 對象代表事件的狀態,比如事件在其中發生的元素、鍵盤按鍵的狀態、鼠標的位置、鼠標按鈕的狀態。
截取字符串
substring() 方法用于提取字符串中介于兩個指定下標之間的字符。
indexOf() 方法可返回某個指定的字符串值在字符串中首次出現的位置。
var a = lifePlanNoteImgPath.substring(lifePlanNoteImgPath.indexOf("upload"));
alert(a)
?請求地址替換
var url= "http://localhost:8081/myAuthorize?name=NAME&pw=PASSWORD";
url = url.replace("NAME","201712170105");//來自緩存中的用戶名
url = url.replace("PASSWORD","170105");//來自緩存中的密碼
console.dir(url);
each循環
$(".ys").each(function(){
console.log($(this).val())
});
數組賦值
var strs_rms= new Array(); //定義一數組
for (var i=0; i < data.length; i++) {
strs_rms.push(data[i].food_num)
};
?字符串分隔
var strs= new Array(); //定義一數組
strs=data[0].fr_sc.split(",");
console.log(strs);
for (var i=0; i < strs.length; i++) {
console.log(strs[i]);
};
?
//給刪除按鈕綁定點擊事件(傳值)
$('.del').on('click',function () {
// 事件處理事件
var idObj = $(':checkbox:checked');
var id = '';
for (var i = 0; i < idObj.length; i++) {
id += idObj[i].value + ',';
}
//去掉最后一個,
id = id.substring(0,id.length -1);
console.log(id);
})
?placeholder的樣式設置
#input-test{ color:?#FFC0CB; font-size:?1.2em; width:?180px; height:?36px; } #input-test::-webkit-input-placeholder{? color:?#ADD8E6; } #input-text::-moz-placeholder{ ?//不知道為何火狐的placeholder的顏色是粉紅色,怎么改都不行,希望有大牛路過幫忙指點 color:?#ADD8E6;? ? ? ?? }? #input-text:-ms-input-placeholder{ ?//由于我的IE剛好是IE9,支持不了placeholder,所以也測試不了(⊙﹏⊙),有IE10以上的娃可以幫我試試? color:?#ADD8E6;? ? ? ??? } html代碼:? <div?id="container"> <input?id="input-test"?type="text"?placeholder="修改placeholder樣式"?/> </div>?獲取weui復選框的值
var inputa = $("input[name='checkbox1']:checked");
for (var i = 0; i < inputa.length; i++) {
console.log(inputa[i].id);
console.log($('#'+inputa[i].id+'').parents('td').next().text());
console.log($('#'+inputa[i].id+'').parents('td').next().next().text());
}
點擊事件嵌套多次觸發問題
jQuery中的click事件會累計綁定,所以我們可以在下次點擊前先解綁
$(".xx").unbind("click").on("click",function(){
});
?
CSS文字溢出
text-overflow:ellipsis屬性來實現單行文本的溢出顯示省略號(…)。當然部分瀏覽器還需要加寬度width屬性
單行:
overflow: hidden;text-overflow: ellipsis;white-space: nowrap;
多行:
?overflow : hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-line-clamp: 2;-webkit-box-orient: vertical;
?
?
?
?
?城別.筆
轉載于:https://www.cnblogs.com/sangwl/p/8579164.html
總結
- 上一篇: 后端接口的幂等性(转)
- 下一篇: 你对博客中提到的评分规则有何意见和建议?