Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery append input value to iframe data-src

How can I append an input value to data-src iframe in jQuery.

var input = $("#input").val();

var iframe = $(".win");
iframe.attr("src", iframe.data("src").join(input)); 
        
console.log(iframe.data("src"));

I am doing like the above snippet but the console.log returns only the initial value without the input value that should be appended.

Does anyone know a way to do it?


1 Answers

You did not update data-src. You updated src attribute.

var input = $("#input").val();

var iframe = $(".win");
iframe.attr("src", iframe.data("src").join(input)); 
    
console.log(iframe.attr("src"));
console.log(iframe.data("src"));
like image 78
Lovely Avatar answered Feb 01 '26 06:02

Lovely



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!