1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-27 02:56:18 -04:00

[js] className setter

This commit is contained in:
Witold Filipczyk 2021-06-03 13:44:57 +02:00
parent 5de45a9e96
commit 7a65feb323
2 changed files with 15 additions and 0 deletions

View File

@ -1384,6 +1384,14 @@ element_set_property_className(JSContext *ctx, unsigned int argc, JS::Value *vp)
return true;
}
xmlpp::Element *el = JS_GetPrivate(hobj);
if (!el) {
return true;
}
std::string value = JS_EncodeString(ctx, args[0].toString());
el->set_attribute("class", value);
return true;
}

View File

@ -11,7 +11,14 @@ function aa()
{
alert(document.getElementById('aaaa').className);
}
function bb()
{
document.getElementById('aaaa').className = 'abc';
alert(document.getElementsByTagName("BODY")[0].outerHTML);
}
</script>
<button onclick="return aa()">Click me!</button>
<button onclick="return bb()">Set className to abc</button>
</body>
</html>