1. Remove spaces.
txt=$.trim($("txt1").val());
2. convert it to a number.
txtNum=Number($.trim(txt)) + 1 thisEle = $("#para").css("font-size"); textFontSize = parseFloat(thisEle , 10);
3, rounded to integer/Random Number
Math.ceil(4.8992303) Math.floor(4.8992303) Math.round(4.8992303) Math.ceil(4.29993354) Math.floor(4.29993354) Math.round(4.29993354) Math.round(Math.random()*100);
4. truncate a string
txt=$("p").text().substr(0,15);
5. String replacement
$("image").attr("src").replace("size=60", "size=200" $("#txt").replace(/[^\d-]/g, "").replace(/^\-/g, "");
6. Split the string
Str = arr = str = "Baidu, Farmer it station, Google, bamboo style, nongfuit.com, webpage chat group, 180550045 welcome to" arr = str. split (','); (I = 0; I <arr. length; I ++}
7. Mutual conversion between js and jquery objects
aa = $("#mm").get(0); bb = $(aa);
8. Use Regular Expression matching
MatchTel =/^ ([0 \ +] \ d {2, 3 }-)? (0 \ d {2, 3})-) (\ d {7, 8}) (-(\ d {3 ,}))? $ /(! MatchTel. test ($ ("# txtTel" alert ("Incorrect phone format! "! 1}