我正在編寫一個網頁應用程序,點擊一些文字應切換line-through
css風格。這適用於Firefox,但在Chrome應用後,Chrome瀏覽器似乎不會觸發Chrome瀏覽器。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","");
}