I just want to insert the variable $src (it fetches the url of an image)
$src = $('a[class="button"]').attr("src");
into this string
$("a[class=panel]").append("--wanna insert $src here--");
How can I do this?
I just want to insert the variable $src (it fetches the url of an image)
$src = $('a[class="button"]').attr("src");
into this string
$("a[class=panel]").append("--wanna insert $src here--");
How can I do this?
var $src = $('a.button').attr("src");
and then:
$('div.panel').append('<div class="zoom-btn"><a href="' + $src + '"></a></div>');
or personally I would prefer:
$('div.panel').append(
$('<div/>', {
'class': 'zoom-btn'
}).append('<a/>', {
href: $src
})
);
This answer isn't relevant now you've gone and completely changed the question after you've posted..
var src = $('a[class="button"]').attr("src");
$("div[class=panel]").append(src);
You mentioned in your question that you want to insert variable $src which fetch the Url of an Image. and for Image we need
$src = $('a[class="button"] img').attr("src","<?=$src?>");
Anchor with "button" class containing image tag
<a href="#" class="button"><img src=""/></a>
and you can also use below code if you don't have element inside anchor.
$src = $('a[class="button"]').append('<img src="<?=$src?>"/>');