11.2編程總結

1.如何讓多個div排列在一行當中input

<input type="text" value="" style="width:25%;">
<input type="text" class="form-control" placeholder="sku" style="width:25%;float: left" maxlength="50">
<style>
.box1 {width:100px; float:left; display:inline;border:red 1px solid;}
.box2 {width:100px; float:left; display:inline;border:green 1px solid;}
</style>
<div class="container">
<div class="box1">121212</div>
<div class="box2">455656</div>
</div>
相關說明:
float 屬性定義元素在哪個方向浮動。
可能的值
值       描述
left    元素向左浮動。  

right    元素向右浮動。    

none    默認值。元素不浮動,並會顯示在其在文本中出現的位置。  

inherit    規定應該從父元素繼承 float 屬性的值。

重點內容

這裏寫代碼片

js問題

ps -ef | grep 8000 查看端口號佔用情況
fa-calculator 計算器

1.js對象去空格
var a=document.getElementById("#name")
a.trim()去掉2端空格
a.ltrim()去掉左邊空格
a.rtrim()去掉右邊空格
2.轉化爲字符串
a.tostring()
1.value.toString()
2."" + value
3.String(value) 

3.獲取input的值
如何用jquery獲取<input id="test" name="test" type="text"/>中輸入的值?

$("#test").val()
$("input[name='test']").val()
$("input[type='text']").val()
$("input[type='text']").attr("value")


4.獲取select 的值
js中獲取方法
var obj = document.getElementByIdx_xx_x(”testSelect”); //定位id
var index = obj.selectedIndex; // 選中索引
var text = obj.options[index].text; // 選中文本
var value = obj.options[index].value; // 選中值

jQuery中獲得選中select值
第一種方式
$('#testSelect option:selected').text();//選中的文本
$('#testSelect option:selected') .val();//選中的值
$("#testSelect ").get(0).selectedIndex;//索引

第二種方式
$("#tesetSelect").find("option:selected").text();//選中的文本
…….val();
…….get(0).selectedIndex;
6.js傳參數
var numParameter = 123;
function sendParameter()
{
getParameter(numParameter );
}
function getParameter(sendNum)
{
alert(sendNum);
} 
7.如何讓輸入的內容自動轉爲首字母大寫的形式
<input name="htmer" type="text" οnkeyup="this.value=this.value.toUpperCase()" /> 
<input type="text" style="*********; text-transform: uppercase;" name="textfield" />

數據庫外鍵主鍵查詢問題

在獲取外鍵以後如何獲取主鍵 待定

生成漂亮的警告彈窗

//產品上架
document.querySelector('ul.dropdown-menu li.ajax a').onclick = function() {
  swal({
    title: '確定要將該產品上架嗎?',
    text: "上架後可以進行銷售!",
    type: 'info',
    showCancelButton: true,
    closeOnConfirm: false,
    showLoaderOnConfirm: true,
  }, function(){
    setTimeout(function() {
      swal('產品上架成功!請刷新頁面');
    }, 2000);
  });
};

//產品下架

document.querySelector('ul.dropdown-menu li.warning.confirm a').onclick = function(){
    swal({
        title: "確定要將該產品下架嗎?",
        text: "下架後可重新上架!",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: '#DD6B55',
        confirmButtonText: 'Yes, delete it!',
        closeOnConfirm: false
    },
    function(){
        swal("Deleted!", "產品下架成功!請刷新頁面", "success");
    });
};
//產品刪除
document.querySelector('ul.dropdown-menu li.warning.cancel a').onclick = function(){
    swal({
        title: "確定要將該產品刪除嗎?",
        text: "產品刪除後將無法進行銷售!",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: '#DD6B55',
        confirmButtonText: 'Yes, delete it!',
        cancelButtonText: "No, cancel plx!",
        closeOnConfirm: false,
        closeOnCancel: false
    },
    function(isConfirm){
    if (isConfirm){
      swal("Deleted!", "產品成功刪除!請刷新頁面", "success");
    } else {
      swal("Cancelled", "產品繼續爲你保留!", "error");
    }
    });
};

獲取選中的輸入框 可以自主輸入文字

<HTML>
<HEAD>
<META http-equiv='Content-Type' content='text/html; charset=utf-8'>
<TITLE>js實現可輸入的下拉框</TITLE>
</HEAD>
<BODY>
<div style="position:relative;">
<span style="margin-left:100px;width:18px;overflow:hidden;">
<select style="width:118px;margin-left:-100px" onchange="this.parentNode.nextSibling.value=this.value">
<option value="德國">德國</option>
<option value="挪威">挪威</option>
<option value="瑞士"> 瑞士</option>
</select></span><input name="box" style="width:100px;position:absolute;left:0px;">
</div>
</BODY>
</HTML>

bootstrap基本css樣式http://v2.bootcss.com/base-css.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章