list-style-position:inside/outside
inside和outside效果
outside
inside
JS部分
- oninput 事件
在 value 改變時觸發,實時的,即每增加或刪除一個字符就會觸發,然而通過 js 改變 value 時,卻不會觸發。
oninput要通過addEventListener() 來添加?
- onchange事件
onchange事件是在輸入框value改變,且失去焦點的情況下觸發,不實時
- onpropertychange事件
IE瀏覽器專有,不管
string方法
- str.match(reg)
參數:一個正則表達式對象
返回:一個數組
如果:
正則表達式對象設置了g(全局)標志,則返回該字符串所有與正則表達式匹配的子元素組成的數組
'123456'.match(/\d/g);
// [ "1", "2", "3", "4", "5", "6" ]
如果沒有設置g(全局)標志,則返回匹配到的第一項
'123456'.match(/\d/g);
['1']
var str = 'For more information, see Chapter 3.4.5.1';
var re = /see (chapter \d+(\.\d)*)/gi;
var found = str.match(re);
console.log(found);
// ["see Chapter 3.4.5.1"]
如果reg參數沒有設置g標志,則返回一個 Array ,它包含所有匹配的子字符串而不是匹配對象
var str = 'For more information, see Chapter 3.4.5.1';
var re = /see (chapter \d+(\.\d)*)/i;
var found = str.match(re);
console.log(found);
// ["see Chapter 3.4.5.1", "Chapter 3.4.5.1", ".1", index: 22, input: "For more information, see Chapter 3.4.5.1"]
// input是被解析的原始字符串
- string.replace(①,②);
參數:
①reg或str
②newStr或function
二參function:一個用來創建新子字符串的函數,該函數的返回值將替換掉第一個參數匹配到的結果
該function的參數
match、p1,p2...、string
match和string一樣?返回的都是原字符串?
p1,p2 假如replace()方法的第一個參數是一個RegExp 對象,則代表第n個括號匹配的字符串。
Element.appendChild(anotherEle)會將被添加的元素從原來的位置移到Element的‘體內’