Hi all,
I have many buttons on one page that all have their own IDs
e.g. <button id="unique">button</button>
When the button is clicked, I need it to add some code to the page beneath it. The added code is the html tag 'iframe' (effectively, clicking the button will add an iframe.
The code will be the same for every iframe except the iframe url will have a unique ID for each one.
So simply -- the idea is
Click BUTTON, show
iFrame with URL containing BUTTONs ID as part of the url
Heres' my code so far:
jQuery:
$(document).ready(function(){
$('.button').click(function(){
// variable to getid
var getid = $(this).attr('id');
// choose the div #show and add text to it. The text is called by the variable.
$("#show").text('<iframe src="getid"></iframe>');
});
});
HTML:
<button id="unique1">Show iFrame button </button>
<div id="show"></div>
--
I'm a newbie to jQuery still and so I'm really lost here. I think perhaps using 'this' within the variable is what it causing problems but I'm not sure. I'm not sure if I should be creating a function instead.
Any pointers or similar solutions much appreciated.
Thanks
Chris.