[英]How do you use javascript to set a variable to a link?
I am making a website that has a course in HTML.我正在制作一个有 HTML 课程的网站。 Every lesson/page on the website will have the same format because I was trying to set a link in a button to a variable surrounded in quotes.
网站上的每个课程/页面都将具有相同的格式,因为我试图将按钮中的链接设置为用引号括起来的变量。 Ex.
前任。
"document.getElementById("completedLessons").innerHTML = "<a href=\"lesson" + lessonsCompleted + ".html"
, then I would set lessonsCompleted to the amount of lessons completed. "document.getElementById("completedLessons").innerHTML = "<a href=\"lesson" + lessonsCompleted + ".html"
,然后我会将课程的课程设置为已完成的课程数量。 Then I put the button at the bottom of my code: <p id="completedLessons"></p><button>Start</button></a>
.然后我把按钮放在我的代码底部:
<p id="completedLessons"></p><button>Start</button></a>
。 My computer has Chrome OS and doesn't have Linux, so it can't run python, PHP, etc.我的电脑有Chrome OS,没有Linux,所以无法运行python、PHP等。
<a id='lessonAnchor' href='not a thing yet'>Lesson Anchor<a>
<script>
document.getElementById('lessonAnchor').href=
"lesson" + lessonsCompleted + ".html";
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.