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

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -