[英]How do I show an element when another element has already been clicked?
I have a link, 我有一个链接,
<a href="manager_view.html">
<p class="in_row">Jane Doe</p>
</a>
I want to show a checkmark, ✓, when Jane Doe has been clicked in the past. 我想显示一个复选标记,✓,当Jane Doe过去被点击时。 How would I do that?
我该怎么办?
JAVASCRIPT JAVASCRIPT
document.getElementsByClassName('in_row')[0].onclick = function()
{
this.className = 'in_row clicked';
}
Or, if you have more than one: 或者,如果您有多个:
var rows = document.getElementsByClassName('in_row');
for (var i = 0, len = rows.length; i < len; i++)
{
rows[i].onclick = doclick; //this function is the above code
}
CSS CSS
.clicked:before
{
content:"✓";
}
You should use local storage http://www.w3schools.com/html/html5_webstorage.asp If you have more elements to store in it you can use JSON.stringify
When you create a array of clicked elements you store it like this 您应该使用本地存储http://www.w3schools.com/html/html5_webstorage.asp如果您有更多要存储的元素,您可以使用
JSON.stringify
当您创建一个点击元素数组时,您可以像这样存储它
localStorage["rowsclick"] = JSON.stringify(elementsClickedArray);
And than to read that you need 而不是阅读你需要的
elementsClickedArray = JSON.parse(localStorage["rowsclick"]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.