_hyperscript
_hyperscript copied to clipboard
Transition parent opacity with bootstrap btn
In the following code, the transition opacity to 0 finish immediately instead of 0.5s.
It only works correctly if the btn class is remove from the button. (line 11)
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/[email protected]"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
</head>
<body>
<div class="parent" style="background-color: red; padding: 5px;">
<span>parent</span>
<button class="child btn btn-danger" style="background-color: orange; padding: 5px;" _="
on click
transition the closest .parent opacity to 0 over 0.5s
remove closest .parent
">
<span>child</span>
</button>
</div>
</body>
</html>
[Note]
- Test on firefox 121.0 and chromium 119.0.
- Insert
wait 0.5sbefore the line ofremove closet .parent(insert to line 14) it will work on firefox but not on chrome. (It is not correct way to use hyperscript anyway)