We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
题目:
已知有如下 HTML 结构,请编写函数 format,实现点击对应按钮后对 #str 文本进行加粗、斜体、上标或下标格式化。
format
提示:请使用 HTML 格式替代方法
<span id="str">儿童节快乐!</span> <p> <button onclick="format(1)">加粗</button> <button onclick="format(2)">斜体</button> <button onclick="format(3)">上标</button> <button onclick="format(4)">下标</button> </p>
参考答案:
function format(type) { let text = str.innerText || str.textContent; let result; switch(type) { case 1: result = text.bold(); break; case 2: result = text.italics(); break; case 3: result = text.sup(); break; case 4: result = text.sub(); break; default: result = text; } str.innerHTML = result; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
题目:
已知有如下 HTML 结构,请编写函数
format
,实现点击对应按钮后对 #str 文本进行加粗、斜体、上标或下标格式化。参考答案:
The text was updated successfully, but these errors were encountered: