Custom javascript not working mobile theme

Posted in: Newspaper
Post count: 96

I am using a little bit of javascript to change the place of the comment section on the mobile theme.
If I test the code on desktop it is working. But on my phone the code is not working:
I use this code:
$(window).on('scroll', function(){
const comments = document.querySelectorAll("#comments")
$('.td-related-title').prepend(comments);
});

I place it in Theme panel -> Mobile theme -> Custom javascript

If I test on desktop code is working -> https://screencast-o-matic.com/watch/cr1vDXV15q8

Post count: 21065

Hello!

I’ve checked your website and it seems to work just well now.
Please clear your cache and try again.

Thank you!

Post count: 96

Hi, I solved the problem.
I used jQuery instead of $ and then the script worked.

See this -> https://mkyong.com/jquery/jquery-is-not-working-in-wordpress-solution/

Post count: 21065

Hello!

I’m glad you have managed to solve the issue.
Let me know if you need further assistance.

Have a nice day!

Viewing 4 posts - 1 through 4 (of 4 total)
The forum ‘Newspaper’ is closed to new topics and replies.