# 6. 插入 HTML 標籤的方法 - innerHTML(2) 變數記錄字串範例 - 練習將屬性及字串用變數的方式來記錄,並載入到 innerHTML: ``` // HTML: <ul class="list"> </ul> ``` ``` // JavaScript: var el = document.querySelector('.list'); // 練習將變數帶入字串 var people = '查理'; var link = 'http://yahoo.com.tw'; // 字串組成方式: el.innerHTML = '<li><a target="_blank" href="' + link + '">' + people + '</a></li>'; ``` ###### tags: `JavaScript - DOM 元素`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up