【发布时间】:2017-08-28 19:06:32
【问题描述】:
我正在编写一个 Web 应用程序,在该应用程序中单击一些文本应该切换 line-through css 样式。这适用于 Firefox,但在应用样式后,click 事件似乎不会在 Chrome 中触发。
HTML:
<script>
$(document).ready({
$(".liner").click(toggleStrikethrough);
});
<div class="liner">
Hello World
</div>
JS(请注意,我使用了 jQuery,因为这是我在应用程序中使用的,但也可以接受普通解决方案):
function toggleStrikethrough()
{
if($(this).css("text-decoration") != "line-through")
$(this).css("text-decoration","line-through");
else
$(this).css("text-decoration","");
}
【问题讨论】:
标签: javascript jquery css google-chrome