![](/img/trans.png)
[英]Function to refresh captcha, works on iPhone, not on desktop browsers
[英]Function works on desktop and emulator but not on mobile browsers
我有一個WordPress Woocomerce網站。 我具有更多/更少閱讀功能,可以擴展/隱藏較長的產品說明。 它在桌面上運行良好。 它甚至可以使用Chrome的移動仿真器工具運行。
但是,它不適用於任何移動瀏覽器。 按下按鈕只會使頁面跳上一點。 我假設瀏覽器沒有讀取.on('click 'touchstart').
:
$(document).ready(function() {
$(".product-readmore").on('click touchstart', function() {
var description = document.querySelector(".product-description-readmore");
if (description.style.height === '') {
description.style.height = 'auto';
} else if (description.style.height === 'auto') {
description.style.height = '';
} else {
description.style.height = '92px';
}
$(this).text($(this).text() == 'Read less...' ? 'Read more...' : 'Read
less...');
});
});
事實證明,問題在於WordPress如何處理jQuery。 我將第一行更改為jQuery(document).ready(function($){
現在,它可以在所有瀏覽器(移動版和其他版本)上正常工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.