我想[标题] 这是我的肆意代码:
<script>
$(document).ready(function(){
var thmbElt = document.getElementsByClassName("imgbox")[0]{var vl1 = $(this).attr("src");};
$(.h_iframe-aparat_embed_frame).attr("src",function{
return "https://www.example.com/video/video/embed/videohash/"+vl1.substr(51, 56)+"/vt/frame";
});
</script>
多数结果是:没有
答案 0 :(得分:0)
如果我理解正确,你想获得一个元素的src并在另一个元素中使用它的一部分。以下是样本:
<img src="https://images.pexels.com/photos/34950/pexels-photo.jpg?h=350&auto=compress&cs=tinysrgb"
class="imgbox" width="80px" height="80px" />
<img src="https://images.pexels.com/photos/34950/pexels-photo.jpg?h=350&auto=compress&cs=tinysrgb"
class="imgbox" width="80px" height="80px" />
<script>
$(document).ready(function(){
var thmbElt = document.getElementsByClassName("imgbox")[0];
var thmbElt1 = document.getElementsByClassName("imgbox")[1]; //Change this line to get img src from another field
var attr = thmbElt1.getAttribute("src");
var attrSubset = "https://www.example.com/video/video/embed/videohash/" + attr.substr(8,6) + "/vt/frame";
thmbElt.setAttribute("src", attrSubset);
});
</script>