利用JavaScript实现如下效果,点击“开始”按钮,,禁用“开始”按钮,文本框(#txt)“1元券、5元券、10元券、20元券、100元券”快速变化,点击“抽奖”按钮,启用“开始”按钮,停止变化同时将停下时的文字填入文本框。点击“开始”按钮继续变化。根据已给出的DOM元素和变量定义写出功能函数。[img=286x128]17e0ce2ae178ec6.png[/img]<;body>;<;p id="txt">;点击“开始”进行抽奖<;/p>;<;input type="text" id="result">;<;input type="button" id="start" value="开始" onclick="start()">;<;button id="stop" onclick="stop()">;抽奖<;/button>;<;/body>;
举一反三
- 将上面代码中的按钮换成下面的按钮,并根据按钮内容实现相应的功能。<;input type="button" value="选择 body内的所有div元素." id="btn1"/>;<;input type="button" value="在body内,选择子元素是div的。" id="btn2"/>;<;input type="button" value="选择 所有class为one 的下一个div元素." id="btn3"/>;<;input type="button" value="选择 id为two的元素后面的所有div兄弟元素." id="btn4"/>;
- 在HTML页面中包含一个按钮控件mybutton,如果要实现点击该按钮时调用已定义的Javascript函数compute,要编写的HTML代码是( )。 未知类型:{'options': ['[input name=”mybutton” type=”button” onClick=”compute” value=”计算”]', '[input name=”mybutton” type=”button” onFocus=”compute()” value=”计算”]', '[input name=”mybutton” type=”button” onClick=”function compute()” value=”计算”]', '[input name=”mybutton” type=”button” onClick=”compute()” value=”计算”]'], 'type': 102}
- 分析下面创建按钮控件的HTML代码,当点击此按钮后产生的结果是 <input type=”button” value=”ok” onClick=”this.style.background=’red’”>
- 在HTML页面中包含一个按钮控件mybutton,如果要实现点击该按钮时调用已定义的Javascript函数compute,要编写的HTML代码是( ) A: <input type="button" name="mybutton" value="计算" onblur="compute()" /> B: <input type="button" name="mybutton" value="计算" onfocus="compute()" /> C: <input type="button" name="mybutton" value="计算" onclick="function compute()" /> D: <input type="button" name="mybutton" value="计算" onclick="compute()" />
- 点击页面中的按钮,使之打开一个新窗口,加载一个网页, 以下JavaScript代码能够实现该功能的是( ) A: input type=”button” value=”new” onclick=”open(‘new.html’,’_blank’)” B: C: D: t;input type=”submit” value=”new” E: t;/form F: t;input type=”button” value=”new” onclick=”location.assign(‘new.html’)”