GetUserEnter = prompt("Please enter whatever you want to say!"); document.write(GetUserEnter);
//Get a random.This will return a number in (0~1) var randomLoc = Math.random(); //If you want get a number in (0~5 haven't 5 like 4.999...) var randomLoc = Math.random() * 5; //Get a complete number: var randomLoc = Math.floor(Math.random() * 5);
function threezh1(varchar, number){ alert("What you wanna to say."); alert("This is the first parameter:" + varchar); alert("This is the second parameter:" + varchar); return0; }
threezh1("Hello World.", 33);
// If a variable is created in outside the function, it is a global variable.
// You can use a variable as a function name. var func = function(num){ ... } func(3);
// No name window.onload = function() { alert("Yeah, that page loaded/1");};
// Get a HtmlElement: var access = document.getElementById("id_name"); var code = access.innerHTML; alert(code); // The "code" is the text of label who id = id_name. // Ps: This codes should be put after the element.
// Change the text of a label: access.innerHTML = "Some other words what you wanna change!";
// If you wanna use a callback function. you can use the window.onload. <script> function init(){ var access = document.getElementById("id_name"); var code = access.innerHTML; alert(code); } window.onload = init; </script>
// Also, you can us setArribute to change the parameter in the table. access.setArribute("class", "redtext"); var ia_name = access.getArribute("id");
转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
Head First Javascript笔记https://cn-sec.com/archives/3547527.html
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.
评论