summernote textarea change youtube url <iframe>
using code :
$video = $('<iframe>') .attr('src', '//www.youtube.com/embed/' + youtubeid) .attr('width', '640').attr('height', '360');
and turns youtube url :
<iframe src="//www.youtube.com/embed/_qxxxxxxc" width="640" height="360" frameborder="0"></iframe>
but want insert bootstrap responsive class, end :
<div class="embed-responsive embed-responsive-16by9"> <iframe class="embed-responsive-item" src="//www.youtube.com/embed/_qxxxxxxc" frameborder="0"></iframe>
i tried modify javascript :
$video = $('<div>').attr('class','embed-responsive embed-responsive-16by9'); $('<iframe>') .attr('class', 'embed-responsive-item') .attr('src', '//www.youtube.com/embed/' + youtubeid) .attr('width', '640').attr('height', '360');
and end result :
<div class="embed-responsive embed-responsive-16by9" frameborder="0"></div>
how keep iframe , add div element? thank you.
try this
$video = $('<iframe>') .attr('class', 'embed-responsive-item') .attr('src', '//www.youtube.com/embed/' + youtubeid) .attr('width', '640').attr('height', '360'); $div = $('<div class="embed-responsive embed-responsive-16by9"></div>').append($video);
your problem was
$video = $('<div>').attr('class','embed-responsive embed-responsive-16by9'); //the semicolon indicates end of line. $video ends here //below line of code nothing. creates iframe mentioned stuff , then???? not put use. $('<iframe>') .attr('class', 'embed-responsive-item') .attr('src', '//www.youtube.com/embed/' + youtubeid) .attr('width', '640').attr('height', '360');
Comments
Post a Comment