I am trying to write a skp nav link script but instead of grabbing the id i want to grab the class. How can I write the following script in jquery syntax to get the class name?
$(document).ready(function() {
$(".ajax-video").click(function(event) {
event.preventDefault();
document.getElementById("currently-playing-title").scrollIntoView();
});
});
Also for some reason the following does not work:
$('.videoplayer').scrollIntoView();
try
$('.videoplayer')a jQuery collection and so you can only run jQuery functions on it.[0]accesses the first DOM element in that collection.Note that if you have more than one element with the
videoplayerclass, you may get unexpected results here. It’s honestly better to use the element ID.If you have multiple elements with
.videoplayer, but only one is visible at a time (tabs, etc), you can also try: