1

Всем привет! У меня есть два дива!

<div id="button"><div>
<div id="main"><iframe src="" width="" height="" ></iframe></div>

Как сделать так чтобы при клике на button, изменялся src в iframe второго дива? Заранее спасибо!

1 ответ 1

4

http://jsfiddle.net/ReinRaus/vTX9A/
jQuery

$('#button').on('click', function() {
    $('#main iframe')[0].src= '/';
});

pureJS

var button2= document.getElementById('button2');
button2.onclick= function() {
    document.getElementById('main').getElementsByTagName('iframe')[0].src="/";
};
1
  • Вы супер!!!
    – DOsS
    16 дек 2013 в 13:42

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.