I'm trying to add an iframe using jquery this way below, but when I click the link it doesn't happen anything.
<head>
<script type="text/javascript"
src='//ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.js'></script>
<script type="text/javascript">
function fun(){
$('<iframe />'); // Create an iframe element
$('<iframe />', {
name: 'frame1',
id: 'frame1',
src: 'http://www.programmingfacts.com'
}).appendTo('body');
</script>
</head>
<body>
<a href="#" onclick="fun()">clica</a>
</body>
</html>
Try this:
<html>
<head>
<script type="text/javascript" src='http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.js'></script>
<script type="text/javascript">
$(document).ready(function() {
$(".submit").click(function()
{
$('<iframe />'); // Create an iframe element
$('<iframe />', {
name: 'frame1',
id: 'frame1',
src: 'http://www.programmingfacts.com'
}).appendTo('body');
});
});
</script>
</head>
<body>
<a href="#" class="submit">clica</a>
</body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With