jquery - How to get src value from the class in the attr? -
.attr('href', 'http://example.com/');
i want link class a.mylink...
like here:
.attr('href', ''); <a href="http://example.com/" class="mylink"></a>
here code
.$('<iframe src="" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>').attr('src', '.link here');
first need call attr function on valid object. leave second parameter out set href attribute. calling without second parameter href attribute object.
getter:
var href = $('.mylink').attr('href');
this store href in variable
setter:
$('.mylink').attr('href','new href value');
this set html to:
<a href='new href value' class='mylink'></a>
in case selector invalid. try instead:
$('iframe').attr('src');
Comments
Post a Comment