I'm trying to have my jQuery script pull the url from the link clicked and then insert it into my video tag. Any advice?
I've tried splicing what I get from .html(), but the quotes always screw it up.
<div class="binShadow">
<div class="bin">
<table id="tableBin" border="0">
<tr>
<th>name</th>
<th>description</th>
<th>location</th>
<th>duration</th>
</tr>
<tbody>
<tr>
<td><a href='clip1234.mov'>Clip1234</a></td>
<td>dolor sit amet, consectetur adipiscing elit</td>
<td>dr101</td>
<td>:60</td>
</tr>
<tr>
<td><a href="clip456.mov">Clip456</a></td>
<td>Lorem ipsum dolor sit amet</td>
<td>dr101</td>
<td>:60</td>
</tr>
</tbody>
</div>
</table>
</div>
</div>
</div>
<script>
$("#tableBin").click(function () {
var url = $(this).html(); //Not even close to working
var overlay = jQuery('<div class="boxWrapper"><div class="box"><video src="'+url+'"</div></div>');
overlay.appendTo(document.body);
});
</script>
You can pull the href directly from the context of the click:
$("#tableBin").on("click", "a", function(e){
e.preventDefault();
url = this.href;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With