I am trying to get the id of the video of an embedded script. This ID changes each time for the video so I would need to grab it somehow.
This is the embed line that is added in the HTML document:
<script src="https://content.jwplatform.com/players/80HZjDPO-V5C9t34F.js"></script>
This is what it generates:
<div id="botr_80HZjDPO_V5C9t34F_div" class="jwplayer jw-reset jw-state-paused jw-stretch-uniform jw-flag-aspect-mode jw-breakpoint-4 jw-flag-user-inactive" tabindex="0" aria-label="Video Player" role="application" style="width: 100%;">
This is the id I want to grab:
id="botr_80HZjDPO_V5C9t34F_div"
I noticed that this is always the same:
botr_ ****** _V5C9t34F_div
How would I be able to grab this id and use it in my Javascript?
You can use $
in the attribute selector to match the end of the string $("div[id$='_V5C9t34F_div']")
.
[name$=”value”]
Description: Selects elements that have the specified attribute with a value ending exactly with a given string. The comparison is case sensitive.