<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>表單操作</title> <script type="text/javascript" src="jquery-1
在編程中總是會遇見很多動態產生的東西,一般我們都是通過簡單的html拼接起來的function createHtml(name, phone, addr, email, imageSrc){ var html = ''; html += '<div class=personInfo>' html += '<p>Name: ' + name + '</p>'; html
話不多說了。先來看兩段代碼:var elems = document.getElementsByTagName('a');for (var i = 0; i < elems.length; i++) {alert(i); elems[i].addEventListener('click', function (e) { e.preventDefault(); alert('I am link #' + i); },