javas学习记录

1.HTML DOM 中类似于querySelector() 等返回文档中匹配指定 CSS 选择器的元素选择的方法,对于括号中书写的是“选择器名称”

语法:document.querySelector(“CSS selectors”);

注意必须书写括号。

2.对于一些特定的元素,在语法规范中往往不需要进行单双引号符号。

father.appendChild(lastli);

father.insertBefore(secondli, father.children[1]);

留言板案例

        btn.onclick = function () {

            if (text.value == '') {

                alert("您没有输入任何内容");

                return false;

            } else {

                /* 你在这里创建一个新的li 也就是每次点击都会生成一个新的li  不然写在上面 每次点击都是这一个内容在改变 */

                var newLi = document.createElement('li');

                newLi.innerHTML = text.value + '<br/>' + "<a href='javascript:;''>删除</a>";

                father.insertBefore(newLi, father.children[1]);

                /* 儿子找爷爷收拾爸爸 */

                /* 循环绑定事件 */

                var as = document.querySelectorAll("a");

                for (var i = 0; i < as.length; i++) {

                    as[i].onclick = function () {

                        /*  father.removeChild(father.children[i]);

                         上面这个做法是非常错误的 因为本来的意思是点击第i个删除链接 会删除第i个对应的文本内容

                         但是忽视了对于删除一次以后,随后的后面的i值都会发生改变 以至于a标签的i与本来对应的文本i值不匹配

                         因此将"father.children[i]"改为"" */

                        father.removeChild(this.parentNode);

                    }

                }

            }

        }


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Multiple-Choice Quiz 1 aaaba aadda 1.Which method must exist in every Java application? (a) main (b) paint (c) begin (d) init 2.Which of the following is the string concatenation operator in Java? (a) + (b) ^ (c) & (d) ++ 3.Which of the following statements is (are) true about the use of an asterisk (*) in a Java import statement? I. It does not incur run-time overhead. II. It can be used to import multiple packages with a single statement. III. It can be used to import multiple classes with a single statement. (a) I and III only (b) III only (c) I only (d) I, II, and III 4.A difference between the methods print and println of the class java.io.PrintWriter is that (a) print inserts a new line at the beginning of its output, but println does not (b) println appends a new line to the end of its output, but print does not (c) println inserts a new line at the beginning of its output, but print does not (d) print appends a new line to the end of its output, but println does not 5.What will be output when the following Java program segment is executed? int x = 5; int y = 2; System.out.println(x + y);//这种运算是顺序进行的,试试System.out.println(x + y + “1”); (a) 7 (b) 5 2 (c) 5+2 (d) 52 6.What is the right way to handle abnormalities in input on Java? (a) By handling these problems by providing exception handlers (b) By writing while loops to guard against bad input (c) By using the class FileFilter which gracefully filters out bad input data (d) By always specifying the throws clause in every method header where file I/O is performed 7.All Java exception classes are derived from the class (a) java.lang.Throwable (b) java.lang.Error (c) java.io.IOException (d) java.lang.RuntimeException
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值